FFmpeg to GstBuffer

fre deric frenky.picasso at seznam.cz
Wed Dec 16 14:53:01 UTC 2020


Hi,
My goal is to push frames by ffmpeg to gst pipeline. For this, I used a
small demo from nvidia. 

I have a raw video file with res: 1920x1080,  fps: 30, format: NV12. I can
read this file using "fread" function and then put it to buffer and push it
to appsrc:

typedef struct _AppSrcData
{
  GstElement *app_source;
  long frame_size;
  FILE *file;                   /* Pointer to the raw video file */
  gint appsrc_frame_num;
  guint fps;                    /* To set the FPS value */
  guint sourceid;               /* To control the GSource */
} AppSrcData;


static gboolean read_data (AppSrcData * data)
{
   GstBuffer *buffer;
   GstFlowReturn gstret;

   size_t ret = 0;
   GstMapInfo map;
   buffer = gst_buffer_new_allocate (NULL, data->frame_size, NULL);

   gst_buffer_map (buffer, &map, GST_MAP_WRITE);
   ret = fread (map.data, 1, data->frame_size, data->file);
   map.size = ret;

   gst_buffer_unmap (buffer, &map);

   gstret = gst_app_src_push_buffer ((GstAppSrc *) data->app_source,
buffer);
  
   data->appsrc_frame_num++;

  return TRUE;
}

My question is, how to replace "fread" function by "libav" library (ffmpeg)
and put data inside the buffer?
I tried to load data to AVFrames and then transform it to the buffer, but I
was unsuccessful. 
In general, my issue is how to transform ffmpeg data (AVFrame, AVPicture,
etc) to the buffer.
 
Thanks for clarifications!
fre deric



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list