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

Multimedia FFMPEG backend emits an error when trying to play a music file with embedded cover image

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 6.6
    • Multimedia
    • None
    • Linux/X11

    Description

      When I set a `MediaPlayer`'s source to a music file with embedded cover image & start playing, the `error` is set to `FormatError` and the `errorString` is "Cannot create codec,Failed to open FFMPEG codec context Invalid argument". In the console I also get the output "[mjpeg_cuvid @ 0x114c040] Codec mjpeg_cuvid is not supported." However the audio continues to play just fine. The error disappears if I change the playback of the file (i.e. play/pause)

      This error does not occur if I set the source to a music file with no embedded cover image.

      If I run `ffmpeg -hwaccels` then cuvid does not appear in the list of hardware acceleration methods. If I run `ffmpeg -hwaccel cuvid -i track.mp3 cover.jpg` then the cover file is successfully extracted with the following output:
      ```
      [mjpeg @ 0x55665d6f00c0] Hardware is lacking required capabilities
      [mjpeg @ 0x55665d6f00c0] Failed setup for format cuda: hwaccel initialisation returned error.
      ```
      so clearly ffmpeg is able to extract a cover file without needing cuvid. Which means maybe Qt is attempting to extract the cover image with cuvid and not allowing ffmpeg to use any fallback methods?

      Hardware/software details:
      Operating System: openSUSE Tumbleweed 20231115
      KDE Plasma Version: 5.27.9
      KDE Frameworks Version: 5.112.0
      Qt Version: 6.6.0
      Kernel Version: 6.6.1-1-default (64-bit)
      Graphics Platform: X11
      Processors: 4 × Intel® Core™ i5-5200U CPU @ 2.20GHz
      Memory: 7.7 GiB of RAM
      Graphics Processor: NVIDIA GeForce 840M/PCIe/SSE2
      Manufacturer: Dell Inc.
      Product Name: Inspiron 5749
      System Version: A09

      Reproducible example (load a track with embedded image, press play, look at the "Current error" label):

      import QtQuick.Controls
      import QtQuick.Dialogs
      import QtMultimedia
      ApplicationWindow {
          visible: true
          width: 600
          height: 600
          AudioOutput {
              id: audioOutput
          }
          MediaPlayer {
              id: mediaPlayer
              audioOutput: audioOutput
          }
          FileDialog {
              id: fileDialog
              fileMode: FileDialog.OpenFile
              currentFolder: StandardPaths.standardLocations(StandardPaths.MusicLocation)[0]
              onAccepted: mediaPlayer.source = selectedFile
          }
          Column {
              Button {
                  text: "Select music file"
                  onClicked: fileDialog.open()
              }
              Button {
                  text: mediaPlayer.playing ? "Pause" : "Play"
                  onClicked: mediaPlayer.playing ? mediaPlayer.pause() : mediaPlayer.play()
              }
              Label {
                  text: "Current file: " + mediaPlayer.source.toString()
              }
              Label {
                  text: "Current status: " + mediaPlayer.mediaStatus
              }
              Label {
                  text: "Playback state: " + mediaPlayer.playbackState
              }
              Label {
                  text: "Current error: " + mediaPlayer.error + " " + mediaPlayer.errorString
              }
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              johanseg Jøger Hansegård
              jackh Jack Hill
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes