Sizing a playback buffer to that of a video

This forum is about all development around libVLC.
opensoar
Blank Cone
Blank Cone
Posts: 10
Joined: 04 May 2016 00:34

Sizing a playback buffer to that of a video

Postby opensoar » 04 May 2016 00:54

First time user of LibVLC. I have working code that opens a video file from a URL and renders it into a 256 x 256 buffer via an OpenGL texture.

Code: Select all

unsigned int texture_width = 256; unsigned int texture height = 256; unsigned int texture_depth = 4; libvlc_video_set_callbacks(media_player, lock, unlock, display, &context); libvlc_video_set_format(media_player, "RV32", texture_width, texture_height, texture_width * texture_depth); libvlc_media_player_play(media_player);
Now I want to optimize it so the buffer is sized to the actual dimensions of the video.

I realize you don't know the size of the video until after it starts playing so currently, I set an arbitrary size for the video at initialization and defer creation of the buffer until my "lock" method is called. I get the video size and set the format like this:

Code: Select all

static void* lock(void* data, void** p_pixels) { ... ... libvlc_video_get_size(context->mp, 0, &video_width, &video_height); libvlc_video_set_format(context->mp, "RV32", video_width, video_height, video_width * 4); ... ...
and create a buffer video_width x video_height x 4 in size. However, the video renders incorrectly - the line pitch is wrong and looks like VLC is still using the value I set at initialization.

Is this the right approach and if so, anyone know what I am doing wrong?

If there is a better way to do this, can you please share details.

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

Re: Sizing a playback buffer to that of a video

Postby Rémi Denis-Courmont » 04 May 2016 10:15

No, it is not. Refer to the Libvlc Doxygen.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

opensoar
Blank Cone
Blank Cone
Posts: 10
Joined: 04 May 2016 00:34

Re: Sizing a playback buffer to that of a video

Postby opensoar » 04 May 2016 18:34

Isn't that more of a resource for looking up functions etc. vs a description of how one is supposed to structure an application?

Can you point me at some sample code?

opensoar
Blank Cone
Blank Cone
Posts: 10
Joined: 04 May 2016 00:34

Re: Sizing a playback buffer to that of a video

Postby opensoar » 06 May 2016 06:21

As a long time VLC developer, I imagine you know exactly how to do this. Care to elaborate or point me at some code?

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

Re: Sizing a playback buffer to that of a video

Postby Rémi Denis-Courmont » 06 May 2016 08:09

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

opensoar
Blank Cone
Blank Cone
Posts: 10
Joined: 04 May 2016 00:34

Re: Sizing a playback buffer to that of a video

Postby opensoar » 06 May 2016 13:37

Really? That's the best you can come up with.

Super helpful. Thank you.

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

Re: Sizing a playback buffer to that of a video

Postby Rémi Denis-Courmont » 06 May 2016 17:10

Would you care to explain why volunteer developers should help you debug your app on their free time, while you can evidently not be bothered to read the documentation?
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

opensoar
Blank Cone
Blank Cone
Posts: 10
Joined: 04 May 2016 00:34

Re: Sizing a playback buffer to that of a video

Postby opensoar » 06 May 2016 17:37

Yes of course.

My post wasn't one of those "hey guys - i need to make app that decodes video - please help. LOL. thanks".

I followed the instructions on your saite for an example that uses SDL, ported it to my Windows code base and got it working. After some experimentation, I discovered that the simple approach didn't appear to let me decode to a buffer that can change size at any point - a feature of the system I am working in and beyond my control.

I didn't post asking for debugging help - merely a pointer to an example snippet or at least a high level approach I can take to implement it. I was planning on releasing all the source code once I got it working for those Windows developers that come after me.

I'm not expecting anyone to spend a large amount of time on this - as experienced developers, I'm sure you know exactly how to do this and a quick list of the sorts of functions I need to string together or a pointer to some existing code - even an overview doc on how to implement this feature - would have been immensely helpful.

"RTFM" was not.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 42 guests