可以通过appsrc将外部的数据添加到gstreamer 的 pipeline中,下面链接是appsrc 的一些说明(可能需要翻墙才能打开,其中还有appsink的一些说明和例子)
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-data-spoof.html
下面是其中的一例子
#include <gst/gst.h> static GMainLoop *loop; static void cb_need_data (GstElement *appsrc, guint unused_size, gpointer user_data) { static gboolean white = FALSE; static GstClockTime timestamp = 0; GstBuffer *buffer; guint size; GstFlowReturn ret; size = 385 * 288 * 2; buffer = gst_buffer_new_allocate (NULL, size, NULL); /* this makes the image black/white */ gst_buffer_memset (buffer, 0, white ? 0xff : 0x0, size); white = !white; GST_BUFFER_PTS (buffer) = timestamp; GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND, 2); timestamp += GST_BUFFER_DU