QMediaRecorder::record() delay on Windows
-
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.
-
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.
-
@SGaist In Release mode I can observe the delay when recording audio. In Debug mode I reached the exception posted in the original message.
Do you have the same issue if you trigger the recoding using the button's clicked signal ?
-
@SGaist In Release mode I can observe the delay when recording audio. In Debug mode I reached the exception posted in the original message.
wrote on 17 Oct 2023, 09:22 last edited by@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")); } }
-
@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")); } }
Might be a silly question but where are you starting the recording ? Is it locally ? On a network drive ?
-
Might be a silly question but where are you starting the recording ? Is it locally ? On a network drive ?
wrote on 19 Oct 2023, 09:14 last edited by@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.
-
@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.
Do you encounter the same issue if you use your application on a different machine ?
-
@SGaist Yes, that is on Windows PCs. I don't see such issue when running my program on MacOS.
Just to be sure I understand this correctly, you have the same issue in several different Windows machines ?
-
Just to be sure I understand this correctly, you have the same issue in several different Windows machines ?
11/11