libvlc_video_set_callbacks

This forum is about all development around libVLC.
mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

libvlc_video_set_callbacks

Postby mika » 26 Oct 2010 16:01

Hi,

I'm conducting research in advanced scheduling of video applications, and I have chosen to use VLC for my experiments.

I want to collect timestamps of frames (when they were displayed). I see that 'libvlc_video_set_callbacks' could be useful, but I have a problem.
I just want to use the 'display' callback, i.e., libvlc_video_set_callbacks(mp, NULL, NULL, display, NULL)

However, I must implement lock and unlock also, otherwise I get runtime errors, e.g., libvlc_video_set_callbacks(mp, lock, unlock, display, NULL)

I dont know how to implement dummy functions for 'lock' and 'unlock'. Having them empty will result in 'segmentation fault'.

Can someone tell me how to implement 'lock' and 'unlock' as dummy functions (without functionality in them and without them causing crashes)?

Cheers, and thx in advance!

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

Re: libvlc_video_set_callbacks

Postby Rémi Denis-Courmont » 26 Oct 2010 17:14

Set the video output format to 1x1 in RV32 and return dummy buffers.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks

Postby mika » 26 Oct 2010 18:10

Thx for the reply,

So I should use something like:

libvlc_video_set_format( mp, "RV32", unsigned width, unsigned height, unsigned pitch );

'width' and 'height' should be the same I guess, what about 'pitch'?

Should 'lock' return dummy buffers? Which data-structures should I use?
I reused code from an example (I have removed some stuff) which looks something like this:

static void *lock(void *data, void **p_pixels) {
return NULL;
}

I'm a real newbie in this (not scheduling but video processing) so please be specific =)

Regards

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_video_set_callbacks

Postby xdenser » 27 Oct 2010 00:12

for Rv32 and frame 1x1 pitch is 4
just return pointer to 4 byte array in p_pixels

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks

Postby mika » 27 Oct 2010 10:46

Thank you,

So it should be something like this:

libvlc_video_set_format(mp, "RV32", 240, 240, 4);

...and what about the 'lock' function?

static void *lock(void *data, void **p_pixels) {
p_pixels = ?
return NULL;
}

Exactly what could I allocate/set to 'p_pixels'?

Regards

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks

Postby mika » 27 Oct 2010 19:42

I'm writing a scientific article for a journal that will be published in a few months, BUT, deadline for submitting the article is in a few days and the experimental data with VLC would really improve it... Basically we are scheduling applications in multiple levels (like a tree) where the VLC app. would be one of the nodes in this tree. The experiments would give time points when frames are displayed, and this is dependent on how much CPU we give to each app. in the tree (incl. the one with the VLC app.). The timepoints could later be used as feedback to the module which distributes the CPU power, thereby giving apps. (like VLC) a dynamic amount of CPU power, enough to give decent video quality. For example, TV's with multiple views can benefit from this. This research is funded by swedish industry and conducted at Malardalen University in Sweden (by me, a doctoral student).

I'm telling this because the motivation for my posting here, and the help needed, is for the sake of research (and not private stuff), which is a gain for everyone...

Anyway, I just need the missing pieces of code, written in my last reply, in order to finish the experiments. I cannot figure out how to make it work =( and i'm 100% new to video processing...so please help...

Regards

xdenser
Blank Cone
Blank Cone
Posts: 23
Joined: 30 Aug 2010 23:39
Contact:

Re: libvlc_video_set_callbacks

Postby xdenser » 27 Oct 2010 21:58

if you need dummy buffer 1x1
then do like that

Code: Select all

libvlc_video_set_format(mp, "RV32", 1, 1, 4);
...

Code: Select all

char dummy_buffer [4]; static void *lock(void *data, void **p_pixels) { *p_pixels = &dummy_buffer; return NULL; }
if you need real size buffer for PAL resolution for example

Code: Select all

libvlc_video_set_format(mp, "RV32", 720, 576, 4*720);
...

Code: Select all

char dummy_buffer [4*720*576]; static void *lock(void *data, void **p_pixels) { *p_pixels = &dummy_buffer; return NULL; }
size of buffer should also make influence on preformance
also take into account - when you use libvlc_video_set_callbacks - you actually should render video yourself in display callback
if you do not - you'll see no video
and rendering in real application also takes some cpu time

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks

Postby mika » 27 Oct 2010 23:13

Hey thank you so much!

But one thing though, is it tricky to render a video? Do you think you could show me a simple example of that... (I will put your name on the article if you want;) )
I want the experiments to be as realistic as possible, so there should at least be some movie being played...

But hey, thanks again, you saved my day!

Cheers

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks

Postby mika » 28 Oct 2010 10:13

One more thing also...

I tried it now and it works, but when I run (a 91 frame long video), the display callback is called more than 91 times... Does VLC repeat the video or?

Regards

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks

Postby mika » 29 Oct 2010 10:44

Hello,

Thanks for all the help. In the end, I was not able to include VLC in the experiments. Executing it in a real-time Linux process (scheduled with the kernel module RESCH) generated a lot of errors from the VLC app., even the computer froze sometimes.

Thx for the support...

Regards


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 13 guests