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

QMediaRecorder::record() delay on Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
multimediarecordingaudioqmediarecorder
11 Posts 2 Posters 1.1k Views
  • 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 12 Oct 2023, 19:41 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 13 Oct 2023, 07:03
    0
    • S SGaist
      12 Oct 2023, 19:41

      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 13 Oct 2023, 07:03 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.

      S S 2 Replies Last reply 14 Oct 2023, 20:00
      0
      • S szumial
        13 Oct 2023, 07:03

        @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
        SGaist
        Lifetime Qt Champion
        wrote on 14 Oct 2023, 20:00 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
          13 Oct 2023, 07:03

          @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 17 Oct 2023, 09:22 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"));
              }
          }
          
          S 1 Reply Last reply 18 Oct 2023, 20:12
          0
          • S szumial
            17 Oct 2023, 09:22

            @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"));
                }
            }
            
            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 18 Oct 2023, 20:12 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 19 Oct 2023, 09:14
            0
            • S SGaist
              18 Oct 2023, 20:12

              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 19 Oct 2023, 09:14 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.

              S 1 Reply Last reply 19 Oct 2023, 19:34
              0
              • S szumial
                19 Oct 2023, 09:14

                @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.

                S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 19 Oct 2023, 19:34 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 20 Oct 2023, 11:19
                0
                • S SGaist
                  19 Oct 2023, 19:34

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

                  S Offline
                  S Offline
                  szumial
                  wrote on 20 Oct 2023, 11:19 last edited by
                  #9

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

                  S 1 Reply Last reply 20 Oct 2023, 18:28
                  0
                  • S szumial
                    20 Oct 2023, 11:19

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

                    S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 20 Oct 2023, 18:28 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 23 Oct 2023, 07:29
                    0
                    • S SGaist
                      20 Oct 2023, 18:28

                      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 23 Oct 2023, 07:29 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

                      11/11

                      23 Oct 2023, 07:29

                      • Login

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