Page 1 of 1
Video format callbacks
Posted: 24 Feb 2019 09:29
by sherington
I've been using libvlc_video_set_format_callbacks successfully for some time, it works but I have a question about the implementation.
I added some debug statements recently and noticed the following behaviour:
Code: Select all
setup chroma=VAOP, size=1280x720
cleanup
setup chroma=VDV0, size=1280x720
cleanup
setup chroma=I420, size=1280x738
So, when I play media (in this case an mp4), I get the format callback three times with different parameters (two of them get a corresponding cleanup), before playback starts.
My callback implementation each time simply sets up the buffer format to be RV32 with same width and height specified.
The question then is while my code appears to work correctly, I'm wondering if this behaviour is normal or if I'm supposed to be doing something differently with these different buffer formats?
Re: Video format callbacks
Posted: 24 Feb 2019 17:58
by Rémi Denis-Courmont
VLC is probing different formats, until it finds one that works.
Re: Video format callbacks
Posted: 24 Feb 2019 22:19
by sherington
Thank you for replying.
What I don't get is that in the first callback VLC probes VAOP and I return RV32, why does it then keep going and probing the other two formats? Why doesn't it accept the RV32 I returned the first time?
I'm just trying to determine if my implementation/understanding of this callback is wrong.
Re: Video format callbacks
Posted: 25 Feb 2019 17:23
by Rémi Denis-Courmont
It cannot find a working path to convert VAOP to RV32.
Re: Video format callbacks
Posted: 26 Feb 2019 09:05
by sherington
It's clear now, thanks a lot.
Re: Video format callbacks
Posted: 28 Jun 2019 09:05
by Tibweizh
Hi Sherington,
I'm facing some problems with my implementation of video format callback, could you please share yours ? Or tell me what you did ?
Thanks
Re: Video format callbacks
Posted: 28 Jun 2019 19:19
by sherington
What do you want to know? My implementation is deeply integrated in a Java library and I can't just cleanly pull the code out unfortunately.
Re: Video format callbacks
Posted: 01 Jul 2019 08:59
by Tibweizh
In your format setup callback, your basics steps. Because mine does not work as I wish
Code: Select all
unsigned VLCReader::cb_setup(void **opaque, char *chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines)
{
VLCReader *p = (VLCReader*)opaque;
memcpy(chroma, "RV24", sizeof("RV24") - 1);
p->m_width = *width;
p->m_height = *height;
*pitches = (*width) * 3;
*lines = *height;
return 1; // indicates the number of buffers allocated
}
This version is crashing but when I remove the multiplication it works but video does not show up entirely (only squares on the top part of my window)
Re: Video format callbacks
Posted: 01 Jul 2019 19:42
by sherington
From a quick look, the only thing I do different is use RV32 format and a pitches value of width*4.
(I'm not saying RV32 is necessary but it was the only useful format I could get to work with the UI toolkit I was using).
You are definitely allocating enough memory for your *3 buffer size?
Re: Video format callbacks
Posted: 02 Jul 2019 08:20
by Tibweizh
Humm I think so but I'll work on this point, thanks mate !
If I succeed I'd tell you
Re: Video format callbacks
Posted: 02 Jul 2019 15:08
by Tibweizh
Ok definitely it came from memory allocation, my buffer was too small but... I found something strange with libvlc_video_get_size
Here it is : the size obtained by libvlc_video_get_size was not the same as the one I get from the calllback setup (unsigned *width and unsigned *height). Is this a bug or whatever else ?
Thanks again mate !
Re: Video format callbacks
Posted: 02 Jul 2019 18:07
by sherington
I am no expert on this, but I suppose certain buffer formats might require e.g. aligning to 8/16/32 bit boundaries and that could explain the discrepancies you are seeing.
So e.g. if the video height is 500, you'd actually need a buffer height of 504 to hold it (504/8 = 63.0 whereas 500/8 = 62.5). I'm just guessing.
In practical terms does it matter? I don't think so.
Re: Video format callbacks
Posted: 03 Jul 2019 09:32
by unidan
It's the difference between visible_size (video size in VLC) and real buffer size (buffer size in VLC). What you get in setup is the size of the video without the padding.
Re: Video format callbacks
Posted: 03 Jul 2019 09:37
by Tibweizh
Oh that's it ! Thank you very much Unidan, it's quite clear now for me