how to get video size?
Posted: 15 Dec 2011 01:23
I am trying to get the size of a video but everything I have tried does not seem to work. Here is what I am trying (after lots of forum browsing and google searches).
I am listening for the events libvlc_MediaParsedChanged and libvlc_MediaMetaChanged (trying both for now until I can get this). Inside the events I am trying two approaches to get the size, the first is:
The second approach is this:
I looked through the source and it looks like libvlc_video_get_size is setup to always fail with a #if 0. Even if that was enabled it appears to be getting the window size and not the native video dimensions (is what I need).
For some background I am trying to get the video size so that I can create my OpenGL textures to the appropriate size for the video to be rendered into as opposed to having libvlc scale the video (which I am trying to avoid).
Thanks.
I am listening for the events libvlc_MediaParsedChanged and libvlc_MediaMetaChanged (trying both for now until I can get this). Inside the events I am trying two approaches to get the size, the first is:
Code: Select all
libvlc_media_track_info_t * tracks = NULL;
libvlc_media_get_tracks_info(media, &tracks);
if( tracks )
{
int width = tracks->u.video.i_width;
int height = tracks->u.video.i_height;
print( "%d x %d", width, height);
free(tracks);
}
else
{
print("tracks is NULL"); <-- this is what happens.
}
Code: Select all
libvlc_video_get_size(player, 0, &width, &height);
print("%d x %d", width, height); <-- "0 x 0" is what gets printed
For some background I am trying to get the video size so that I can create my OpenGL textures to the appropriate size for the video to be rendered into as opposed to having libvlc scale the video (which I am trying to avoid).
Thanks.