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

No audio is recorded using qt camera examples, widget/qml

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.8.2, 6.9.0
    • 6.7.1, 6.8
    • Multimedia
    • None

      There is no audio stream in video files recorded with the widget camera example or the declarative camera example. Tested with two different webcams. One of the cameras is able to record audio using the audiorecorder example. See below logs produced with

      QT_FFMPEG_DEBUG=true
      QT_LOGGING_RULES=*.ffmpeg.*=true
      

       

       

      Output from widget example using Qt 6.7.1 binary installation:

      "FFmpeg log: Requested input sample format -1 is invalid"

      ...
      qt.multimedia.ffmpeg.utils: ---------------------------
      qt.multimedia.ffmpeg.v4l2camera: XXXXX QV4L2Camera(0x5822c73a3850) "/dev/video0" Format_Jpeg QSize(2560, 1440)
      qt.multimedia.ffmpeg.v4l2camera: setting camera format to QSize(2560, 1440) 1196444237
      qt.multimedia.ffmpeg.encoder: recording new media to "/home/odeon/Videos/video_0268.mp4"
      qt.multimedia.ffmpeg.encoder: requested format: QMediaFormat::MPEG4 QMediaFormat::AudioCodec::AAC
      "FFmpeg log: Setting default whitelist 'file,crypto,data'"
      qt.multimedia.ffmpeg.encodingformatcontext: opened by file path: /home/odeon/Videos/video_0268.mp4 , result: 0
      qt.multimedia.ffmpeg.audioencoder: AudioEncoder QMediaFormat::AudioCodec::AAC
      qt.multimedia.ffmpeg.audioencoder: found audio codec aac
      qt.multimedia.ffmpeg.audioencoder: set stream time_base 1 / 96000
      qt.multimedia.ffmpeg.encoder: adding video source QV4L2Camera : pixelFormat= Format_Jpeg frameSize= QSize(2560, 1440) frameRate= 30 ffmpegHWPixelFormat= -1
      qt.multimedia.ffmpeg.hwaccel: No hw acceleration found for codec id 12
      qt.multimedia.ffmpeg.videoencoder: found encoder mpeg4 for id 12
      qt.multimedia.ffmpeg.videoencoder: Adjusted frame rate: 30 / 1
      qt.multimedia.ffmpeg.videoencoder: codecContext time base 1 30000
      qt.multimedia.ffmpeg.videoencoder: video source and encoder use different formats: 28 0 or sizes: QSize(2560, 1440) QSize(2560, 1440)
      qt.multimedia.ffmpeg.videoencoder: VideoFrameEncoder conversions initialized: sourceFormat: 28 (sw) targetFormat: 0 (sw) sourceSWFormat: 28 targetSWFormat: 0 converter: 0x5822cbbe85c0
      qt.multimedia.ffmpeg.encoder: RecordingEngine::start!
      qt.multimedia.ffmpeg.encoder: stream header is successfully written
      qt.multimedia.ffmpeg.muxer: Muxer::init started thread.
      qt.multimedia.ffmpeg.videoencoder: VideoEncoder::init started video device thread.
      "FFmpeg log: detected 8 logical cores"
      qt.multimedia.ffmpeg.audioencoder: Most likely, av_format_write_header changed time base from 1 / 0 to 1 / 96000
      "FFmpeg log: For transform of length 1024, forward, mdct_float, flags: [aligned, out_of_place], found 2 matches:"
      "FFmpeg log:     1: "
      "FFmpeg log: mdct_fwd_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only], prio: 96"
      "FFmpeg log:     2: "
      "FFmpeg log: mdct_naive_fwd_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only], prio: -130976"
      "FFmpeg log: For transform of length 512, forward, fft_float, flags: [aligned, inplace, preshuf], found 5 matches:"
      "FFmpeg log:     1: "
      "FFmpeg log: fft_sr_ns_float_avx2 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 480"
      "FFmpeg log:     2: "
      "FFmpeg log: fft_sr_ns_float_fma3 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 448"
      "FFmpeg log:     3: "
      "FFmpeg log: fft_sr_ns_float_avx - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 416"
      "FFmpeg log:     4: "
      "FFmpeg log: fft_pfa_ns_float_c - type: fft_float, len: [6, ∞], factors[2]: [7, 5, 3, 2, any], flags: [unaligned, inplace, out_of_place, preshuf], prio: 112"
      "FFmpeg log:     5: "
      "FFmpeg log: fft512_ns_float_c - type: fft_float, len: 512, factor: 2, flags: [unaligned, inplace, out_of_place, preshuf], prio: 96"
      "FFmpeg log: Transform tree:"
      "FFmpeg log:     "
      "FFmpeg log: mdct_fwd_float_c - type: mdct_float, len: 1024, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]"
      "FFmpeg log:     "
      "FFmpeg log:     "
      "FFmpeg log: fft_sr_ns_float_avx2 - type: fft_float, len: 512, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]"
      "FFmpeg log: For transform of length 128, forward, mdct_float, flags: [aligned, out_of_place], found 2 matches:"
      "FFmpeg log:     1: "
      "FFmpeg log: mdct_fwd_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only], prio: 96"
      "FFmpeg log:     2: "
      "FFmpeg log: mdct_naive_fwd_float_c - type: mdct_float, len: [2, ∞], factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only], prio: -130976"
      "FFmpeg log: For transform of length 64, forward, fft_float, flags: [aligned, inplace, preshuf], found 5 matches:"
      "FFmpeg log:     1: "
      "FFmpeg log: fft_sr_ns_float_avx2 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 480"
      "FFmpeg log:     2: "
      "FFmpeg log: fft_sr_ns_float_fma3 - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 448"
      "FFmpeg log:     3: "
      "FFmpeg log: fft_sr_ns_float_avx - type: fft_float, len: [64, 131072], factor: 2, flags: [aligned, inplace, out_of_place, preshuf], prio: 416"
      "FFmpeg log:     4: "
      "FFmpeg log: fft_pfa_ns_float_c - type: fft_float, len: [6, ∞], factors[2]: [7, 5, 3, 2, any], flags: [unaligned, inplace, out_of_place, preshuf], prio: 112"
      "FFmpeg log:     5: "
      "FFmpeg log: fft64_ns_float_c - type: fft_float, len: 64, factor: 2, flags: [unaligned, inplace, out_of_place, preshuf], prio: 96"
      "FFmpeg log: Transform tree:"
      "FFmpeg log:     "
      "FFmpeg log: mdct_fwd_float_c - type: mdct_float, len: 128, factors[2]: [2, any], flags: [unaligned, out_of_place, fwd_only]"
      "FFmpeg log:     "
      "FFmpeg log:     "
      "FFmpeg log: fft_sr_ns_float_avx2 - type: fft_float, len: 64, factor: 2, flags: [aligned, inplace, out_of_place, preshuf]"
      "FFmpeg log: intra_quant_bias = 0 inter_quant_bias = -64"
      qt.multimedia.ffmpeg.audioencoder: audio codec opened 0
      qt.multimedia.ffmpeg.audioencoder: audio codec params: fmt= 8 rate= 96000
      "FFmpeg log: Requested input sample format -1 is invalid"
      qt.multimedia.ffmpeg.audioencoder: AudioEncoder::init started audio device thread.
      qt.multimedia.ffmpeg.videoencoder: video codec opened 0 time base 1 / 30000
      qt.multimedia.ffmpeg.encoder: >>>> adjusting base time to 2523986 2523986 0
      qt.multimedia.ffmpeg.encoder: >>> sending frame 0 0 33333
      qt.multimedia.ffmpeg.videoencoder: sending frame 0 * 1 / 30000
      qt.multimedia.ffmpeg.videoencoder: got a packet 0 0 0
      qt.multimedia.ffmpeg.encoder: >>> sending frame 960 32003 65336
      ...

       

      Output from widget example using dev built from source, linked to FFmpeg 7.0:

      "qt.multimedia.ffmpeg.encoder: Stream initialization error: "Audio device has invalid preferred format" <- shown as a popup

      ...
      qt.multimedia.ffmpeg.utils: ---------------------------
      qt.multimedia.ffmpeg.v4l2camera: XXXXX QV4L2Camera(0x631ed4c7f730) "/dev/video0" Format_Jpeg QSize(2560, 1440)
      qt.multimedia.ffmpeg.v4l2camera: setting camera format to QSize(2560, 1440) 1196444237
      qt.multimedia.ffmpeg.encoder: recording new media to "/home/odeon/Videos/video_0265.mp4"
      "FFmpeg log: Setting default whitelist 'file,crypto,data'"
      qt.multimedia.ffmpeg.encodingformatcontext: opened by file path: /home/odeon/Videos/video_0265.mp4 , result: 0
      qt.multimedia.ffmpeg.encoder: requested format: QMediaFormat::MPEG4 QMediaFormat::AudioCodec::AAC
      qt.multimedia.ffmpeg.encoder: >>>>>>>>>>>>>>> initialize
      qt.multimedia.ffmpeg.encoder: Stream initialization error: "Audio device has invalid preferred format"
      qt.multimedia.ffmpeg.encoder: adding video source QV4L2Camera : pixelFormat= Format_Jpeg frameSize= QSize(2560, 1440) frameRate= 30 ffmpegHWPixelFormat= -1
      qt.multimedia.ffmpeg.hwaccel: No hw acceleration found for codec id 12
      qt.multimedia.ffmpeg.videoencoder: found encoder mpeg4 for id 12
      qt.multimedia.ffmpeg.videoencoder: Adjusted frame rate: 30 / 1
      qt.multimedia.ffmpeg.videoencoder: codecContext time base 1 30000
      qt.multimedia.ffmpeg.videoencoder: video source and encoder use different formats: 28 0 or sizes: QSize(2560, 1440) QSize(2560, 1440)
      qt.multimedia.ffmpeg.videoencoder: VideoFrameEncoder conversions initialized: sourceFormat: 28 (sw) targetFormat: 0 (sw) sourceSWFormat: 28 targetSWFormat: 0 converter: 0x631ed845e300
      qt.multimedia.ffmpeg.encoder: RecordingEngine::start!
      qt.multimedia.ffmpeg.encoder: stream header is successfully written
      qt.multimedia.ffmpeg.muxer: Muxer::init started thread.
      qt.multimedia.ffmpeg.videoencoder: VideoEncoder::init started video device thread.
      "FFmpeg log: detected 8 logical cores"
      "FFmpeg log: intra_quant_bias = 0 inter_quant_bias = -64"
      qt.multimedia.ffmpeg.videoencoder: video codec opened 0 time base 1 / 30000
      qt.multimedia.ffmpeg.videoencoder: >>>> adjusting base time to 6635995 6635995 0
      qt.multimedia.ffmpeg.videoencoder: >>> sending frame 0 0 6669328
      qt.multimedia.ffmpeg.videoencoder: sending frame 0 * 1 / 30000
      qt.multimedia.ffmpeg.videoencoder: got a packet 0 0 0
      qt.multimedia.ffmpeg.videoencoder: >>> sending frame 1079 35978 6705306
      ... 

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            lars.sutterud Lars Sutterud
            lars.sutterud Lars Sutterud
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes