Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-127444

QMediaRecorder does not start recording on darwin backend

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.1, 6.7.2, 6.8.3, 6.9
    • Multimedia
    • None
    • macOS
    • Multimedia wk 31-32, Multimedia wk 35-38

    Description

      QMediaRecorder does not start recording on darwin backend

      Mac mini intel core i5, MacOS Sonoma 14.5

      When using the darwin backend (via the environment variable QT_MEDIA_BACKEND=darwin), the QMediaRecorder::recorderStateChanged signal does not emit with the QMediaRecorder::RecordingState state, but no errors occur:

      "Logitech Webcam C920-C"
      Qt::PermissionStatus::Granted
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      on_pushRecord_clicked() QMediaRecorder::NoError "" 

      I am attaching a minimal project for reproduction and result of test_audio_config utility.

      Update 0

      The problem is caused by the fact that the number of audio channels is not specified before recording starts, and the same problem occurs when explicitly called before recording starts:

      audioRecorder->setAudioChannelCount(-1);
      // (this call assumes that the number of channels will be selected automatically). 

      When explicitly specifying, for example, two channels:

      audioRecorder->setAudioChannelCount(2); 

      recording starts i.e. The QMediaRecorder::recorderStateChanged() QMediaRecorder::RecordingState signal is emitted.

      However, another problem arises. One recording cycle is successful, but if you then start recording again, the following will happen. Immediately after the QMediaRecorder::recorderStateChanged() QMediaRecorder::RecordingState signal, I catch the QMediaRecorder::errorOccurred() QMediaRecorder::FormatError "An unknown error occurred (-12737)" signal and then the QMediaRecorder::recorderStateChanged() QMediaRecorder::StoppedState signal. And this concludes the recording.

      Here's the relevant output:

      "Logitech Webcam C920-C"
      Qt::PermissionStatus::Granted
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      QMediaRecorder::recorderStateChanged() QMediaRecorder::RecordingState
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      QMediaRecorder::recorderStateChanged() QMediaRecorder::StoppedState
      on_pushRecord_clicked() QMediaRecorder::NoError ""
      QMediaRecorder::recorderStateChanged() QMediaRecorder::RecordingState
      QMediaRecorder::errorOccurred() QMediaRecorder::FormatError "An unknown error occurred (-12737)"
      QMediaRecorder::recorderStateChanged() QMediaRecorder::StoppedState 

      Update 1

      If I set audio input before each staring of recording and remove after each ending of recording then I get specified problem (QMediaRecorder::errorOccurred() QMediaRecorder::FormatError "An unknown error occurred (-12737)"):

       

      captureSession.setAudioInput(new QAudioInput(this));
      //...
      audioRecorder->record();
      
      // ...
      void onRecorderStateChanged(QMediaRecorder::RecorderState state)
      //...
          case QMediaRecorder::StoppedState:
              captureSession.setAudioInput({});

       

       

      But if I set audio input once before first starting of recording then the problem is gone.

      When I use QT_MEDIA_BACKEND=ffmpeg the problem doesn't observed no matter when the audio input is set.

      I attach source code for each case.

      Update 2

      There is new data on the specified error An unknown error occurred (-12737) and also on the error in which instead of adequate audio data in the resulting audio file there is random noise, I indicate two errors in one bug, since both are fixed by one fix (I will also provide it on gerrit).
      Noise instead of correct audio recording appears periodically in the resulting audio files when recording on macOS on the Intel platform (when using the Qt media library Darwin backend) and when using wireless Apple AirPods headphones. The error An unknown error occurred (-12737) also appears on macOS on the Intel platform (when using the Qt media library Darwin backend) when using headphones (headphones + microphone) Bloody Gaming Audio Device (A4Tech Bloody G500) during the first attempt to record after starting the application or during the first attempt to record on the specified headphones after they were set as a recording device after recording from some other device.

      Attachments

        1. AudioRecordTestSimple.zip
          5 kB
          rumgot
        2. test_audio_config_res.txt
          24 kB
          rumgot
        3. AudioRecordTestSimpleFormatError.zip
          5 kB
          rumgot
        4. AudioRecordTestSimpleWithoutErrors.zip
          5 kB
          rumgot

        Issue Links

          For Gerrit Dashboard: QTBUG-127444
          # Subject Branch Project Status CR V

          Activity

            People

              tpochep Timur Pocheptsov
              rumgot rumgot
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change