Page 1 of 1

Problems with libvlc_video_set_callbacks() When using vlc_3.0

Posted: 28 Feb 2018 08:33
by haha459862
First, I describe my application scenario:

1, my video input source is from the network, using the RTSP protocol;
2, I need to get the data of each frame and use it for custom rendering.
3. Before drawing, I need to get the video resolution and frame rate to create a suitable buffer.
4, I use functions libvlc_media_parse_with_options (), libvlc_media_tracks_get (), libvlc_video_set_callbacks () and libvlc_video_set_format_callbacks ().

In the process of programming, I met the following questions:

1, I need to get the video resolution and frame rate, so I use libvlc_media_parse_with_options () function and listen to libvlc_MediaParsedChanged event, then use libvlc_media_get_parsed_status () function to obtain the status of the parse, but the return value is always libvlc_media_parsed_status_skipped. Why?

2, I found that the libvlc_video_set_format_callbacks() function always callback three times. The first time, Chroma is "DX11", resolution is 1280 x 720, the second time Chroma is "DXA9", resolution is 1280 x 720, the third time Chroma is "I420", resolution is 1280 * 738. But the functions in vlc_2.8 only callback one time. Why? How should I use this callback function?

3, I found that there is resolution information in set format callback function, but there is no frame frequency information. Therefore, I use libvlc_media_tracks_get () function to retrieve video information in callback function, but all the parameters are 0. How do I get the resolution and frame rate correctly?

Thanks in advance for help or any code snippet.

Re: Problems with libvlc_video_set_callbacks() When using vlc_3.0

Posted: 28 Feb 2018 17:47
by Rémi Denis-Courmont
1. VLC cannot preparse RTSP.
2. VLC tries to negotiate GPU surfaces, and fails.
3. The resolution is available from the format callback, and there is no concept of frequency at that level.

Re: Problems with libvlc_video_set_callbacks() When using vlc_3.0

Posted: 01 Mar 2018 04:12
by haha459862
How do I get the resolution and frame rate correctly for my application?

Re: Problems with libvlc_video_set_callbacks() When using vlc_3.0

Posted: 03 Mar 2018 22:35
by umod.47
If you get callback for every frame, you can just calculate framerate using time difference between callbacks.

The correct place to allocate frame buffer is in format callback.
Reallocate it each time new callback happens (you can use realloc for that).
At least, this is how I made it in my application.

Re: Problems with libvlc_video_set_callbacks() When using vlc_3.0

Posted: 03 Mar 2018 23:02
by Rémi Denis-Courmont
The resolution is provided to the format callback. Frame rate is not exposed as not all video have a regular frame rate, and VLC is not frame accurate.