how to get video size?

This forum is about all development around libVLC.
mirswith
Blank Cone
Blank Cone
Posts: 49
Joined: 15 Dec 2011 01:15

how to get video size?

Postby mirswith » 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:

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. }
The second approach is this:

Code: Select all

libvlc_video_get_size(player, 0, &width, &height); print("%d x %d", width, height); <-- "0 x 0" is what gets printed
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.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: how to get video size?

Postby Jean-Baptiste Kempf » 15 Dec 2011 03:22

Did you play before getting the infos?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

mirswith
Blank Cone
Blank Cone
Posts: 49
Joined: 15 Dec 2011 01:15

Re: how to get video size?

Postby mirswith » 15 Dec 2011 04:42

Do you mean by calling libvlc_media_player_play? Yah, I have tried that.. I've tried getting the size in the libvlc_MediaPlayerTimeChanged event just to see if I ever received anything valid; never do.

I am wondering if it is because I am setting callbacks with libvlc_video_set_callbacks. All the examples I see that use that send in a pre-determined video size but as mentioned before I want to render the native video size to a texture and to do that I need to know what the actual size is to create my textures with.

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: how to get video size?

Postby Rémi Denis-Courmont » 15 Dec 2011 07:52

The native size is passed to the callback. That is the only correct glitch-free and race-free way to adjust display video in its native resolution.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mirswith
Blank Cone
Blank Cone
Posts: 49
Joined: 15 Dec 2011 01:15

Re: how to get video size?

Postby mirswith » 15 Dec 2011 08:51

Which callback? I noticed there is libvlc_video_set_format_callbacks which looks like what i need however there are two problems with it. 1) it does not accept a void * user data parameter and 2) I get a linking error if I try to use it. I am using the headers from the latest source tree and built a .lib from the 1.1.11 binaries.

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: how to get video size?

Postby Rémi Denis-Courmont » 15 Dec 2011 12:32

set_format_callbacks uses the same opaque pointer as set_callbacks. That's why...
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mirswith
Blank Cone
Blank Cone
Posts: 49
Joined: 15 Dec 2011 01:15

Re: how to get video size?

Postby mirswith » 15 Dec 2011 19:11

Is there a solution to use this callback?

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: how to get video size?

Postby Rémi Denis-Courmont » 15 Dec 2011 21:29

Yeah, libvlc 1.2.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mirswith
Blank Cone
Blank Cone
Posts: 49
Joined: 15 Dec 2011 01:15

Re: how to get video size?

Postby mirswith » 15 Dec 2011 21:50

:) ok, i'll check it out. Thanks.

Monty811
New Cone
New Cone
Posts: 4
Joined: 08 Jan 2012 16:37

Re: how to get video size?

Postby Monty811 » 08 Jan 2012 19:49

Hi there,

i have tried to use the "libvlc_video_set_format_callbacks" with VLC 1.2 because I would like to achieve the same with VLC; get the original video size to be able to create a 3D texture with the same (original) size as the video. Then any resizing will be moved from VLC to the graphics card which should be faster...
My problem is that I would only like to get the original size without modifying something. From the documentation I do understand that I also have to pass parameters back to the function but whatever I try it seems to fail and result in an exception (I use the nigthly build for windows, but debugging into it does not work right now...).
My understanding of the parameters of the function is:

Code: Select all

static unsigned formatCallback (void **opaque, char *chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines) { VLC_InputBase::kVideoBuffer* pVideoBuffer = (VLC_InputBase::kVideoBuffer*) (*opaque); unsigned nWidth = (*width); unsigned nHeight = (*height); (*pitches) = nWidth * 4; (*lines) = nHeight; return 1; }
What am I doing wrong :D ?

Thanks for any help,

Ben

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: how to get video size?

Postby Rémi Denis-Courmont » 08 Jan 2012 21:51

You're not using the chroma parameter. This cannot be correct.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 15 guests