<div dir="ltr">Thanks Tim! That got me unblocked. May I ask hopefully one final question? :)<div><br></div><div>I am now trying to add the "appsrc name=thumbnailer ! jpegenc ! filesink location=thumb.jpg " pipeline to my now working pipeline with the fakesink.</div><div><br></div><div>The following launch line works fine, </div><div><br></div><div>$ gst-launch-1.0 -e v4l2src device=/dev/video1 ! tee name=t t. ! queue ! videoconvert ! videorate ! x264enc ! mpegtsmux ! filesink location=test_stream.ts t. ! queue max-size-bytes=0 max-size-time=0 max-size-buffers=0 ! fakesink name=snapshotter   appsrc name=thumbnailer ! jpegenc ! filesink location=thumb.jpg<br></div><div><div>Setting pipeline to PAUSED ...</div><div>Pipeline is live and does not need PREROLL ...</div><div>Setting pipeline to PLAYING ...</div><div>New clock: GstSystemClock</div><div>Redistribute latency...</div><div>  C-c C-chandling interrupt.</div><div>Interrupt: Stopping pipeline ...</div><div>EOS on shutdown enabled -- Forcing EOS on the pipeline</div><div>Waiting for EOS...</div><div>Got EOS from element "pipeline0".</div><div>EOS received - stopping pipeline...</div><div>Execution ended after 0:00:03.865664400</div><div>Setting pipeline to PAUSED ...</div><div>Setting pipeline to READY ...</div><div>Setting pipeline to NULL ...</div><div>Freeing pipeline ...</div></div><div><br></div><div>But actually I'm trying to replicate this in a C program, and despite launching the exact same pipeline, it hangs indefinitely before getting into the PLAYING state (sometimes I get a libjpeg EOS error). I'll attach the whole program just in case this snippet doesn't describe enough context, but here's what I'm doing,</div><div><br></div><div><div>int main(...) {</div><div>  ...</div><div>  descr =</div><div>    g_strdup_printf ("v4l2src device=/dev/video1 ! tee name=t "</div><div><span class="" style="white-space:pre">             </span>     "t. ! queue ! videoconvert ! videorate ! x264enc ! mpegtsmux ! filesink location=test_stream.ts "</div><div><span class="" style="white-space:pre">         </span>     "t. ! queue max-size-bytes=0 max-size-time=0 max-size-buffers=0 ! fakesink name=snapshotter  "</div><div><span class="" style="white-space:pre">           </span>     " appsrc name=thumbnailer ! jpegenc ! filesink location=thumb.jpg ");</div><div><br></div><div>  printf("launch line: %s\n", descr);</div><div>  pipeline = gst_parse_launch (descr, &error);</div></div><div><br></div><div><div>  gst_element_set_state (pipeline, GST_STATE_PLAYING);</div><div><br></div><div>  /* wait until it's up and running or failed    << THIS CALL HANGS SOMETIMES >> */</div><div>  if (gst_element_get_state (pipeline, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE) {</div><div>    g_error ("Failed to go into PLAYING state");</div><div>  }</div><div><br></div><div>  g_print ("Running ...\n");<br></div><div>  g_main_loop_run (loop);</div></div><div>  ...</div><div>}</div><div><br></div><div><div>$ gcc fakesink_test.c $(pkg-config --cflags gtk+-3.0 gstreamer-1.0) -o fake_sink_test $(pkg-config --libs gstreamer-1.0 gtk+-3.0)</div><div>charlie:[gstreamer]$ ./fake_sink_test</div><div>launch line: v4l2src device=/dev/video1 ! tee name=t t. ! queue ! videoconvert ! videorate ! x264enc ! mpegtsmux ! filesink location=test_stream.ts t. ! queue max-size-bytes=0 max-size-time=0 max-size-buffers=0 ! fakesink name=snapshotter   appsrc name=thumbnailer ! jpegenc ! filesink location=thumb.jpg </div><div>// tumbleweed</div><div>  C-c C-c</div><div><br></div><div><br></div><div>I can copy n' paste my printf output labelled "launch line" above and I don't see a stall. There must be something wrong with my state management, but I can't think what else I should do.</div><div><br></div><div>Thanks very much for your help,</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 9 June 2016 at 11:48, Tim Müller <span dir="ltr"><<a href="mailto:tim@centricular.com" target="_blank">tim@centricular.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On Thu, 2016-06-09 at 11:23 +0100, Charlie Turner wrote:</div><div><br></div><div>Hi Charlie,</div><blockquote type="cite"><div dir="ltr"><span class=""><div><br></div><div>If I run a time "tee'd" pipeline like this,</div><div><br></div></span><div><span class=""><div> gst-launch-1.0 -e v4l2src  device=/dev/video0 ! tee name=t    \</div><div>     t. ! queue ! x264enc ! filesink location=fakesink_test.raw     \</div><div>     t. ! queue ! fakesink</div><div><br></div><div>I see the following output in my terminal,</div></span><div> (snip)</div></div><span class=""><div>And when I look at the "fakesink_test.raw" file, I see that it's zero bytes. Something appears to be getting blocked in the above minimal example.</div><div><br></div><div>If I remove the x264enc element, the pipeline works as I expect it to, producing a suitably large file,</div><div></div></span></div><pre></pre></blockquote><div><br></div><div>The problem is that x264enc with default settings consumes about 3 seconds of video before outputting anything, but queue's default size is only ~1 second. Which means the fakesink branch queue will run full and block, and the x264enc branch will never receive enough data for x264enc to output a buffer (and make the pipeline as a whole preroll).</div><div><br></div><div>You can work around this by making the queue before fakesink unlimited in size:</div><div><br></div><div>  ! queue max-size-bytes=0 max-size-time=0 max-size-buffers=0 ! fakesink</div><div><br></div><div>or by configuring x264enc differently, e.g.</div><div><br></div><div>  x264enc tune=zerocopy</div><div><br></div><div>(other parameters will also help, this is just the easiest, but it will affect quality)</div><div><br></div><div>Cheers</div><span class="HOEnZb"><font color="#888888"><div> -Tim</div><div><br></div><div><span><pre><pre>-- 
</pre>Tim Müller, Centricular Ltd - <a href="http://www.centricular.com" target="_blank">http://www.centricular.com</a>
</pre></span></div></font></span></div><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Kind regards,</div>Charlie Turner</div></div>
</div>