<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi<br>
</p>
<p><br>
</p>
<p>I'm trying to set-up a video encoder pipeline using an appsrc to squirt in raw video from my app and then extract the encoded frames from an appsink:<br>
</p>
<p><br>
</p>
<p>appsrc -> rawvideoparse -> x264enc -> appsink<br>
</p>
<p><br>
</p>
<p>I've attached a log of everything of interest (sorry for the formatting, it wasn't taken from a terminal window and has the escape chars in. Sublime has a nice syntax plugin for displaying it but for some reason you can't copy it grrr).<br>
</p>
<p>The last few lines of the log are pasted below and below that is a snippet from the source code configuring the pipeline.<br>
</p>
<p><br>
</p>
<p>It feels like it's a caps issue but I can't see anything too obvious. I have tried without the rawvideoparse element as well and it makes no difference.<br>
</p>
<p><br>
</p>
<p>I have followed the same code pattern as the <a href="https://gstreamer.freedesktop.org/documentation/tutorials/basic/short-cutting-the-pipeline.html?gi-language=c">
basic-tutorial-8.c</a> example for the most part but it's an audio example, not video.<br>
</p>
<p><br>
</p>
<p>As a test I removed the appsrc and replaced it with a videotestsrc and that worked fine so I'm happy with the appsink.<br>
</p>
<p><br>
</p>
<p>Any suggestions would be gratefully received.<br>
</p>
<p><br>
</p>
<p>Gary.<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p><br>
</p>
<div>0:00:08.016851745  8181 0x7fff6c007ad0 FIXME                default gstutils.c:3981:gst_pad_create_stream_id_internal:<video_source:src> Creating random stream-id, consider implementing a deterministic way of creating
 a stream-id</div>
<div>0:00:08.016924133  8181 0x7fff6c007ad0 INFO                GST_PADS gstpad.c:4232:gst_pad_peer_query:<video_source:src> pad has no peer</div>
<div>0:00:08.016991764  8181 0x7fff6c007ad0 INFO               GST_EVENT gstevent.c:814:gst_event_new_caps: creating caps event video/x-raw, format=(string)I420, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1,
 width=(int)352, height=(int)288</div>
<div>0:00:08.017022797  8181 0x7fff6c007ad0 INFO               GST_EVENT gstevent.c:895:gst_event_new_segment: creating segment event default segment start=0, offset=0, stop=-1, rate=1.000000, applied_rate=1.000000, flags=0x00,
 time=0, base=0, position 0, duration -1</div>
<div>0:00:08.017057838  8181 0x7fff6c007ad0 INFO                 basesrc gstbasesrc.c:2945:gst_base_src_loop:<video_source> marking pending DISCONT</div>
<div>0:00:08.017280495  8181 0x7fff6c007ad0 INFO                 basesrc gstbasesrc.c:2965:gst_base_src_loop:<video_source> pausing after gst_pad_push() = not-linked</div>
<div>0:00:08.017364757  8181 0x7fff6c007ad0 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<video_source> error: Internal data stream error.</div>
<div>0:00:08.017432686  8181 0x7fff6c007ad0 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<video_source> error: streaming stopped, reason not-linked (-1)</div>
<div>0:00:08.017486608  8181 0x7fff6c007ad0 INFO        GST_ERROR_SYSTEM gstelement.c:2145:gst_element_message_full_with_details:<video_source> posting message: Internal data stream error.</div>
<div>gst_video: Error: 1(Operation not permitted) message=Internal data stream error.</div>
<div>gst_video: Debug: gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:video-encoder-pipeline/GstAppSrc:video_source:</div>
<div>streaming stopped, reason not-linked (-1)</div>
<div><br>
<div><span style="white-space:pre"></span><span style="font-family: "Courier New", monospace; font-size: 10pt;">st->streamer.source = gst_element_factory_make("appsrc", "video_source");</span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">st->streamer.parser = gst_element_factory_make("rawvideoparse", "video_parser");</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">st->streamer.encoder = gst_element_factory_make(st->streamer.element, "video_encoder");</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">st->streamer.sink = gst_element_factory_make("appsink", "video_sink");</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">st->streamer.pipeline = gst_pipeline_new("video-encoder-pipeline");</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">if (!st->streamer.source || !st->streamer.parser || !st->streamer.encoder || !st->streamer.sink
 || !st->streamer.pipeline) {</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">warning("gst_video: unable to create one or more of the pipeline elements for the video encoder.\n");</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">err = EPROTO;</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">return err;</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">}</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">/* Configure appsource */</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">//gst_video_info_set_interlaced_format(&info, GST_VIDEO_FORMAT_I420, GST_VIDEO_INTERLACED_MODE_INTERLEAVED,
 size->w, size->h);</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">//video_caps = gst_video_info_to_caps(&info);</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">video_caps = gst_caps_new_simple ("video/x-raw",</span></span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 10pt;">      "format", G_TYPE_STRING, "I420",</span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 10pt;">      "framerate", GST_TYPE_FRACTION, st->encoder.fps, 1,</span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 10pt;">      "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,</span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 10pt;">      "width", G_TYPE_INT, size->w,</span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 10pt;">      "height", G_TYPE_INT, size->h,</span></div>
<div><span style="font-family: "Courier New", monospace; font-size: 10pt;">      NULL);</span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">g_object_set(st->streamer.source, "caps", video_caps, "format", GST_FORMAT_DEFAULT, NULL);</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">gst_app_src_set_callbacks(GST_APP_SRC(st->streamer.source), &(st->streamer.appsrcCallbacks),</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">  st, (GDestroyNotify)appsrc_destroy_notify_cb);</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">/* Configure encoder */</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">// TODO: not hardcode this but do it by parsing options and checking if an actual property</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">g_object_set(st->streamer.encoder, "byte-stream", TRUE, "rc-lookahead", 0, "tune", 4, "speed-preset",
 1, "sync-lookahead", 0, "bitrate", st->encoder.bitrate / 1000, NULL);</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">/* Configure appsink. */</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">g_object_set(st->streamer.sink, "caps", video_caps, NULL);</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">gst_app_sink_set_callbacks(GST_APP_SINK(st->streamer.sink), &(st->streamer.appsinkCallbacks),</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">   st, (GDestroyNotify)appsink_destroy_notify_cb);</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">gst_caps_unref(video_caps);</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">/* Link everything up inside our pipeline */</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">gst_bin_add_many(GST_BIN(st->streamer.pipeline), st->streamer.source, st->streamer.parser,
 st->streamer.encoder, st->streamer.sink, NULL);</span></span></div>
<div><br style="font-family: "Courier New", monospace; font-size: 10pt;">
</div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">/* Bus watch */</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">bus = gst_pipeline_get_bus(GST_PIPELINE(st->streamer.pipeline));</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">gst_bus_set_sync_handler(bus, (GstBusSyncHandler)bus_sync_handler_cb,</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">st, (GDestroyNotify)bus_destroy_notify_cb);</span></span></div>
<div><span style="font-size: 10pt;"><span style="white-space: pre; font-family: "Courier New", monospace;"></span><span style="font-family: "Courier New", monospace;">gst_object_unref(GST_OBJECT(bus));</span></span></div>
<div><br>
<br>
</div>
<br>
</div>
<p><br>
</p>
</body>
</html>