Page 1 of 1

Accessing artwork image data from libVLC

Posted: 15 May 2022 19:54
by neosettler
Greetings,

After parsing a media, libVLC libvlc_media_get_meta does returns libvlc_meta_ArtworkURL as :

attachment://picture0.jpg.

Could someone help shed some light on how to extract the image data to let say, export the image data as an external file? I'm simply interested on how to access the image data here.

Thank you,

Re: Accessing artwork image data from libVLC

Posted: 16 May 2022 09:36
by RĂ©mi Denis-Courmont
That is a placeholder URL for data embedded into the media source.

Re: Accessing artwork image data from libVLC

Posted: 16 May 2022 14:19
by unidan
There's nothing in VLC 3 that can help you. In VLC 4, you'll be able to get a libvlc_picture_t as event from the media player for that. You can check how the medialibrary is doing it: https://code.videolan.org/videolan/medi ... e.cpp#L110

Re: Accessing artwork image data from libVLC

Posted: 09 Jun 2022 05:26
by neosettler
Thank you for your support, I'm a bit confused here, there is no trace of VLCMetadataService::onAttachedThumbnailsFound inside the 4.0 source code snapshot. Is there a comprehensive example on how to use this feature we can chew on?

Re: Accessing artwork image data from libVLC

Posted: 18 Jun 2022 20:40
by neosettler
As of 2022-05-19, while a jpg format picture is valid, libvlc_picture_get_width and libvlc_picture_get_height returns 0. Log doesn't say anything special. Here's a code snippet:

Code: Select all

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #if ZEN_SUPPORT_VLC4 void ZVideoVLC::SetThumbnail(libvlc_picture_t *in_picture) { ZenValidate(in_picture); UInt l_w = libvlc_picture_get_width(in_picture); UInt l_h = libvlc_picture_get_height(in_picture); if (l_w == 0 || l_h == 0) { ZenError("Invalid thumbnail size."); return; } size_t l_size; const UChar *l_buffer = libvlc_picture_get_buffer(in_picture, &l_size); libvlc_picture_type_t l_type = libvlc_picture_type(in_picture); e_PixelFormats l_format = l_type == libvlc_picture_type_t::libvlc_picture_Argb ? ZEN_RGBA8 : ZEN_RGB8; m_Thumbnail = new ZImage(l_w, l_h, l_format); m_Thumbnail->SetPixels((UChar *)l_buffer); libvlc_picture_release(in_picture); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void ZVideoVLC::CallbackThumbnailsFound(const libvlc_event_t *in_event, void *in_data) { ZenValidate(in_event->type == libvlc_MediaAttachedThumbnailsFound); libvlc_picture_list_t *l_thumbnails = in_event->u.media_attached_thumbnails_found.thumbnails; Int64 l_count = libvlc_picture_list_count(l_thumbnails); ZenValidate(l_count > 0); ZVideoVLC *l_video = static_cast<ZVideoVLC *>(in_data); l_video->SetThumbnail(libvlc_picture_list_at(l_thumbnails, 0)); } #endif //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Bool ZVideoVLC::ParseMedia(libvlc_media_t *in_media, const libvlc_media_parse_flag_t &in_flags) { std::mutex l_mutex; std::condition_variable l_cv; std::unique_lock<std::mutex> l_lock(l_mutex); #if ZEN_SUPPORT_VLC4 libvlc_event_attach(m_MediaEventManager, libvlc_MediaAttachedThumbnailsFound, CallbackThumbnailsFound, this); #endif Int l_return = libvlc_media_parse_with_options(in_media, in_flags, -1); l_cv.wait(l_lock); #if ZEN_SUPPORT_VLC4 libvlc_event_detach(m_MediaEventManager, libvlc_MediaAttachedThumbnailsFound, CallbackThumbnailsFound, this); #endif OnMediaParsedEvent(); return l_return == 0; }
Any ideas what's missing?