How to extract cover art from a media file using Qt Libraries
-
I'm trying to extract cover art from a media file.
My application is QML Application. I have to feed the extracted cover image from media file from Qt to QML.I tried as following:
@gui->setProperty("coverImage", (this->metaData("CoverArtImage")))@where this is QMediaPlayer class
gui is QQuickItem
coverImage is a string property in qml file.I'm giving this coverImage as source inside Image element.
I came to know there is some conversion issue here, from Image to providing it as a string etc.
When I tested this:
@qDebug() << this->metaData("CoverArtImage").type();@it returned QVariant::Invalid
How should I do this?
Thanks & Regards,
inblueswithu -
What type of media file are you reading?
Did you also try the CoverArtUrlSmall/CoverArtUrlLarge?
Are you sure your media file has a cover-art embedded? -
Im feeding mp3 files only. I'm sure few songs in my list have a Cover Art. Windows 8 music player app recognized them. If needed, I can give that song too for testing.
Ya. I tried it.
@qDebug() << this->metaData("CoverArtImage").type();
qDebug() << this->metaData("CoverArtUrlLarge");
qDebug() << this->metaData("CoverArtUrlSmall");@They too gave the same result.
@QVariant::Invalid
QVariant(Invalid)
QVariant(Invalid) @ -
Anyone tried this???
-
[quote author="inblueswithu" date="1385402782"]I'm sure few songs in my list have a Cover Art. [/quote]
Are you really sure? I'm asking because i wouldn't be surprised when the player just loads the coverart from the internet based on the artist and title provided. Use some tool which really reads the metadata from the media file (a quick google search came up with "this":http://id3tageditor.com/ for example)As a safe fall back i would recommend to use a free 3rd party lib for this. For example: "TagLib":http://taglib.github.io/
-
Ya. I have seen them before but failed to compile successfully. So, I chose to use default Qt libs.
I didn't want to increase size of my application by adding these 3rd party libs. But it seems inevitable in my present situation.
-
@raven-worx said in How to extract cover art from a media file using Qt Libraries:
What type of media file are you reading?
Did you also try the CoverArtUrlSmall/CoverArtUrlLarge?
Are you sure your media file has a cover-art embedded?
@raven-worxReviving this old topic.
The CoverArtUrlSmall/CoverArtUrlLarge would only give URL's to existing files not to embedded inside the audio file right? -
Hi
yes its just URL (path) -
@mrjj
hello,can you explain me how to set song cover into an Image in qml please?
after loading song,i have this object from metadata :QVariant(QImage, QImage(QSize(1000, 1000),format=QImage::Format_RGB32,depth=32,devicePixelRatio=1,bytesPerLine=4000,sizeInBytes=4000000))
how can i find and use this Qimage url?should i set something to source attr of Image?i have no idead :((
thank you for helping -
Hi
I think you you would use an image provider to send to QML
like here
https://stackoverflow.com/questions/20691414/qt-qml-send-qimage-from-c-to-qml-and-display-the-qimage-on-gui
the "Use an image provider" answer.