user2798392 user2798392 - 1 month ago 26x
C++ Question

working with VLC smem

I'm trying to do something like this post :
Get frame from video with libvlc smem and convert it to opencv Mat. (c++)

I can't quite understand the code in this part :

, "#transcode{vcodec=RV24}:smem{"
, (long long int)(intptr_t)(void*)&cbVideoPrerender
, (long long int)(intptr_t)(void*)&cbVideoPostrender //This would normally be useful data, 100 is just test data
, (long long int)200 //Test data

It says
. What does it mean? Where is it taking data from?

I am getting my file using a file dialog . Can I pass that file to video-data?


rather than using the smem output driver of VLC, i would suggest to interact directly with libvlc, via the mediaplayer interface:

/* user_data is the pointer we passed to `video_set_callbacks()` */
void*lock_frame(void*user_data, void**planes) {
   /* make '*plane* point to a memory you want the video-data rendered to */
  return user_data->pic;
void unlock_frame(void *user_data, void *picture, void *const *planes) {
   /* image rendered into (*planes)==user_data->img; */

unsigned format_callback(void**user_data_ptr; char*chroma, unsigned *width, unsigned *height, unsigned *pitches, unsigned *lines) {

   /* set the output format to RGBA */
   memcpy(chroma, "RV32", 4); /* 'RV32' is 'RGBA'
   /* leave dimensions intact, but store them
    * now's the time to resize user_data->img to hold that much memory
   user_data->width =*width;
   *pitches=(*width)*4; /* 4 is the pixel size for RGBA */

   return 1;

vlc_inst=libvlc_new (0, 0);
libvlc_media_t*media = libvlc_media_new_location (vlc_inst, location);
                         lock_frame, unlock_frame,
                         0, user_data);
libvlc_video_set_format_callbacks(data->m_mediaplayer, format_callback,0);


/* the media-player will call 
 *  - format_callback() with a format suggestion which you can adjust to your needs
 *  - lock_frame()/unlock_frame() whenever a new frame has arrived.
 * once you are done, call: */