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.
-
@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")); } }
-
@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.