Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaRecorder::record() delay on Windows
Forum Updated to NodeBB v4.3 + New Features

QMediaRecorder::record() delay on Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
multimediarecordingaudioqmediarecorder
11 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Do you have the same issue if you run in release mode ? Debug mode can sometime incur performance hit that can explain such behaviour.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Do you have the same issue if you run in release mode ? Debug mode can sometime incur performance hit that can explain such behaviour.

      S Offline
      S Offline
      szumial
      wrote on last edited by
      #3

      @SGaist In Release mode I can observe the delay when recording audio. In Debug mode I reached the exception posted in the original message.

      SGaistS S 2 Replies Last reply
      0
      • S szumial

        @SGaist In Release mode I can observe the delay when recording audio. In Debug mode I reached the exception posted in the original message.

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Do you have the same issue if you trigger the recoding using the button's clicked signal ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • S szumial

          @SGaist In Release mode I can observe the delay when recording audio. In Debug mode I reached the exception posted in the original message.

          S Offline
          S Offline
          szumial
          wrote on last edited by
          #5

          @szumial Yes, it happens also when I trigger the recording using the "clicked" signal.

          Whatever I do, there is always a noticeable delay. Before the recorder goes to RecordingState it is around 3 seconds when I trigger recording for the first time. Consecutive times have a slightly smaller delay time.

          Here is a sample of my code:

          // QMediaRecorder settings
          m_recorder.setMediaFormat({QMediaFormat::MP3});
          m_recorder.setAudioChannelCount(1);
          m_recorder.setQuality(QMediaRecorder::Quality::VeryHighQuality);
          m_recorder.setEncodingMode(QMediaRecorder::ConstantQualityEncoding);
          
          // Pushbutton connections
          connect(recordButton, &QToolButton::pressed, this, [this]
          {
              record(true);
          });
          connect(recordButton, &QToolButton::released, this, [this]
          {
              record(false);
          });
          
          // Record method
          void MyWidget::record(bool on)
          {
              if (on)
              {
                  recordButton->setChecked(true);
          	QDir{}.mkpath(m_outputPath); 
                  m_recorder.setOutputLocation(QUrl::fromLocalFile(m_recordedFile));
          	m_audio->recorder().record();
          	recordButton->setText(tr(" Recording..."));
              }
              else
              {
                  recordButton->setChecked(false);
                  m_recorder.stop();
          	recordButton->setText(tr(" Start recording"));
              }
          }
          
          SGaistS 1 Reply Last reply
          0
          • S szumial

            @szumial Yes, it happens also when I trigger the recording using the "clicked" signal.

            Whatever I do, there is always a noticeable delay. Before the recorder goes to RecordingState it is around 3 seconds when I trigger recording for the first time. Consecutive times have a slightly smaller delay time.

            Here is a sample of my code:

            // QMediaRecorder settings
            m_recorder.setMediaFormat({QMediaFormat::MP3});
            m_recorder.setAudioChannelCount(1);
            m_recorder.setQuality(QMediaRecorder::Quality::VeryHighQuality);
            m_recorder.setEncodingMode(QMediaRecorder::ConstantQualityEncoding);
            
            // Pushbutton connections
            connect(recordButton, &QToolButton::pressed, this, [this]
            {
                record(true);
            });
            connect(recordButton, &QToolButton::released, this, [this]
            {
                record(false);
            });
            
            // Record method
            void MyWidget::record(bool on)
            {
                if (on)
                {
                    recordButton->setChecked(true);
            	QDir{}.mkpath(m_outputPath); 
                    m_recorder.setOutputLocation(QUrl::fromLocalFile(m_recordedFile));
            	m_audio->recorder().record();
            	recordButton->setText(tr(" Recording..."));
                }
                else
                {
                    recordButton->setChecked(false);
                    m_recorder.stop();
            	recordButton->setText(tr(" Start recording"));
                }
            }
            
            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Might be a silly question but where are you starting the recording ? Is it locally ? On a network drive ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply
            0
            • SGaistS SGaist

              Might be a silly question but where are you starting the recording ? Is it locally ? On a network drive ?

              S Offline
              S Offline
              szumial
              wrote on last edited by
              #7

              @SGaist I am recording the microphone input to a local drive.

              I was wondering if moving the recorder logic to a separate thread could improve it, but initial trials did not bring any benefits.

              Another idea I have is a silly workaround to start recording at program start in order for any QMediaRecorder resources to be initialized before I trigger the recording with that pushbutton. This would not solve the root cause of the problem, but maybe improve user experience at least.

              SGaistS 1 Reply Last reply
              0
              • S szumial

                @SGaist I am recording the microphone input to a local drive.

                I was wondering if moving the recorder logic to a separate thread could improve it, but initial trials did not bring any benefits.

                Another idea I have is a silly workaround to start recording at program start in order for any QMediaRecorder resources to be initialized before I trigger the recording with that pushbutton. This would not solve the root cause of the problem, but maybe improve user experience at least.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Do you encounter the same issue if you use your application on a different machine ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply
                0
                • SGaistS SGaist

                  Do you encounter the same issue if you use your application on a different machine ?

                  S Offline
                  S Offline
                  szumial
                  wrote on last edited by
                  #9

                  @SGaist Yes, that is on Windows PCs. I don't see such issue when running my program on MacOS.

                  SGaistS 1 Reply Last reply
                  0
                  • S szumial

                    @SGaist Yes, that is on Windows PCs. I don't see such issue when running my program on MacOS.

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Just to be sure I understand this correctly, you have the same issue in several different Windows machines ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    S 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Just to be sure I understand this correctly, you have the same issue in several different Windows machines ?

                      S Offline
                      S Offline
                      szumial
                      wrote on last edited by
                      #11

                      @SGaist That is correct. The same application tested on different Windows machines presents exactly the same behavior.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved