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

QMediaMetaData CoverArtImage from AVStream (FFMPEG)

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • Not Evaluated
    • None
    • 6.5.0
    • Multimedia
    • Windows

    Description

      At this moment (6.5.0) QMediaPlayer will not load the cover image from an audio file (windows, ffmpeg).

      But the QMediaMetaData object will have a video codec (e.g. MotionJPEG) and when loaded in the "video widget example" the cover is indeed visible in the video output.

      Would it not be consistent to get the cover as QImage in the MediaMetaData object also directly?

      This is possible with ffmpeg, for example:

      extern "C" {
         #include <libavformat/avformat.h>
      }
      
      QImage coverArt;
      
      QString data = song->path(); 
      QByteArray ba = data.toUtf8();
      const char *path = ba.constData();
      
      AVFormatContext *format_song = NULL;
      result = avformat_open_input(&format_song, path, NULL, NULL);
      
      if(result < 0){
               qInfo() << "File could not be opend";
      } else {
         
         for (int i = 0; i < format_song->nb_streams; ++i) {      
            AVStream *stream = format_song->streams[ i ];
            if (stream->disposition & AV_DISPOSITION_ATTACHED_PIC) {
               AVPacket pkt = stream->attached_pic;
               coverArt = QImage::fromData( ( uchar* )pkt.data, pkt.size );
               break;
            }
         }
      } 

      Thanks for consideration. Best wishes and happy coding.

      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
              lfv Lucas Voges
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes