Hi,
I used the deepstream-appsrc-test sample from DeepStream sample apps in C, where the GStreamer pipeline uses a appsrc element. This deepstream sample takes data from raw video file and transform it to GstBuffer .
However, my goal is to take AVFrame from libav (ffmpeg) and transform it to GstBuffer , but I can not find any solution.
Here is part of code from the deepstream-appsrc-test pushing the buffers from video file to appsrc :
typedef struct _AppSrcData
{
GstElement *app_source;
long frame_size;
FILE *file;
gint appsrc_frame_num;
guint fps;
guint sourceid;
} 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);
// Read frame from raw video file.
ret = fread (map.data, 1, data->frame_size, data->file);
map.size = ret;
gst_buffer_unmap (buffer, &map);
// Push buffer to appsrc element.
gstret = gst_app_src_push_buffer ((GstAppSrc *) data->app_source, buffer);
data->appsrc_frame_num++;
return TRUE;
}
My question is, how to tranform data from AVFrame to GstBuffer, instead of video file to GstBuffer.
Setup:
• DeepStream Version 5.0
Please refer to AVFrame data structure and API description from ffmpeg FFmpeg: AVFrame Struct Reference , the document of GstBuffer from Gsteamer GstBuffer .
AppSrcData is the interface for appsrc to get data from outside the gstreamer pipeline. You can define and implement your own read_data() callback for get data from AVFrame. More information, please refer to appsrc (gstreamer.freedesktop.org) Basic tutorial 8: Short-cutting the pipeline (gstreamer.freedesktop.org)
There are also lot of 3rd party appsrc samples, e.g. GStreamer Streaming AppSrc Example (github.com)
1 Like
Thank you. I found a solution in gst-libav:
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>,
* <2006> Edward Hervey <bilboed@bilboed.com>
* <2006> Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
This file has been truncated. show original
1 Like