Using libVLC as a video decoder

This forum is about all development around libVLC.
slavik262
New Cone
New Cone
Posts: 2
Joined: 05 May 2013 00:10

Using libVLC as a video decoder

Postby slavik262 » 05 May 2013 02:23

I'm attempting to use libVLC as a video decoder for a motion detection project. Previously I was using ffmpeg libraries, but some issues with Matroska files brought me here. Along with playing video back at the correct rate, I also want to be able to get one frame after another at the fastest rate my system can handle, as once the user sets up some parameters, I want the motion detection algorithm to run through the video as quickly as it can. My libVLC setup code looks like this (error handling and minor details omitted for brevity):

Code: Select all

const char* vlc_argv[] = { "--no-audio", /* skip any audio track */ }; libvlc_instance_t* inst = libvlc_new(sizeof(vlc_argv) / sizeof(*vlc_argv), vlc_argv); auto media = libvlc_media_new_path (inst, filename.c_str()); player = libvlc_media_player_new_from_media(media); libvlc_media_release(media); // Needed to initialize the player ? libvlc_media_player_play(player); libvlc_media_player_pause(player); fps = libvlc_media_player_get_fps(player); length = libvlc_media_player_get_length(player); width = libvlc_video_get_width(player); height = libvlc_video_get_height(player); // TODO: Add libvlc_video_set_callbacks to set up callbacks to render to memory buffer
However, I am left with the following questions:
  1. Is there a more straightforward way to initialize the media player without starting playback besides calling libvlc_media_player_play then libvlc_media_player_pause?
  2. All of the get functions (fps, length, width, height) all return zero. Do I need to do something like read the first frame to get these values, and if so, how am I supposed to know how large my decoded frame buffer must be?

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

Re: Using libVLC as a video decoder

Postby Rémi Denis-Courmont » 05 May 2013 05:47

The regular playback system is really not meant for unpaced decoding. You'd need to use stream output, for which there is no programmable API as yet.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

slavik262
New Cone
New Cone
Posts: 2
Joined: 05 May 2013 00:10

Re: Using libVLC as a video decoder

Postby slavik262 » 05 May 2013 16:27

Thanks for the response - that is unfortunate but understandable. At any rate, do you know why the get function calls are returning 0?

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

Re: Using libVLC as a video decoder

Postby Rémi Denis-Courmont » 05 May 2013 17:17

You need to wait until the tracks are created.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

rogerdpack
Big Cone-huna
Big Cone-huna
Posts: 574
Joined: 19 Jul 2008 23:48
Operating System: windows

Re: Using libVLC as a video decoder

Postby rogerdpack » 26 Jan 2015 07:45



Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 10 guests