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?