<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1499806908743_2603">I'm still fighting against the avdec_h264 latency problem.</div><div id="yui_3_16_0_ym19_1_1499806908743_2604">The pipeline (which I translated into C code) on my receiver is:</div><div id="yui_3_16_0_ym19_1_1499806908743_2605"><br id="yui_3_16_0_ym19_1_1499806908743_2606"></div><div id="yui_3_16_0_ym19_1_1499806908743_2607">gst-launch-1.0 -v souphttpsrc location=http://127.0.0.1:8080/stream.ts ! tsdemux name=demuxer demuxer. ! h264parse ! avdec_h264 ! autovideosink</div><div id="yui_3_16_0_ym19_1_1499806908743_2608"><br id="yui_3_16_0_ym19_1_1499806908743_2609"></div><div id="yui_3_16_0_ym19_1_1499806908743_2610"><br></div><div id="yui_3_16_0_ym19_1_1499806908743_2610">In gstavviddec.c  the following lines reduce the latency if the upstream is live:<br></div><div id="yui_3_16_0_ym19_1_1499806908743_2613"><br id="yui_3_16_0_ym19_1_1499806908743_2614"></div><div id="yui_3_16_0_ym19_1_1499806908743_2615"><br id="yui_3_16_0_ym19_1_1499806908743_2616"></div><div id="yui_3_16_0_ym19_1_1499806908743_2617">  {</div><div id="yui_3_16_0_ym19_1_1499806908743_2618">    GstQuery *query;</div><div id="yui_3_16_0_ym19_1_1499806908743_2619">    gboolean is_live;</div><div id="yui_3_16_0_ym19_1_1499806908743_2620"><br id="yui_3_16_0_ym19_1_1499806908743_2621"></div><div id="yui_3_16_0_ym19_1_1499806908743_2622">    if (ffmpegdec->max_threads == 0) {</div><div id="yui_3_16_0_ym19_1_1499806908743_2623">      if (!(oclass->in_plugin->capabilities & CODEC_CAP_AUTO_THREADS))</div><div id="yui_3_16_0_ym19_1_1499806908743_2624">        ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();</div><div id="yui_3_16_0_ym19_1_1499806908743_2625">      else</div><div id="yui_3_16_0_ym19_1_1499806908743_2626">        ffmpegdec->context->thread_count = 0;</div><div id="yui_3_16_0_ym19_1_1499806908743_2627">    } else</div><div id="yui_3_16_0_ym19_1_1499806908743_2628">      ffmpegdec->context->thread_count = ffmpegdec->max_threads;</div><div id="yui_3_16_0_ym19_1_1499806908743_2629"><br id="yui_3_16_0_ym19_1_1499806908743_2630"></div><div id="yui_3_16_0_ym19_1_1499806908743_2631">    query = gst_query_new_latency ();</div><div id="yui_3_16_0_ym19_1_1499806908743_2632">    is_live = FALSE;</div><div id="yui_3_16_0_ym19_1_1499806908743_2633">    /* Check if upstream is live. If it isn't we can enable frame based</div><div id="yui_3_16_0_ym19_1_1499806908743_2634">     * threading, which is adding latency */</div><div id="yui_3_16_0_ym19_1_1499806908743_2635">    if (gst_pad_peer_query (GST_VIDEO_DECODER_SINK_PAD (ffmpegdec), query)) {</div><div id="yui_3_16_0_ym19_1_1499806908743_2636">      gst_query_parse_latency (query, &is_live, NULL, NULL);</div><div id="yui_3_16_0_ym19_1_1499806908743_2637">    }</div><div id="yui_3_16_0_ym19_1_1499806908743_2638">    gst_query_unref (query);</div><div id="yui_3_16_0_ym19_1_1499806908743_2639"><br id="yui_3_16_0_ym19_1_1499806908743_2640"></div><div id="yui_3_16_0_ym19_1_1499806908743_2641">    if (is_live)</div><div id="yui_3_16_0_ym19_1_1499806908743_2642">      ffmpegdec->context->thread_type = FF_THREAD_SLICE;</div><div id="yui_3_16_0_ym19_1_1499806908743_2643">    else</div><div id="yui_3_16_0_ym19_1_1499806908743_2644">      ffmpegdec->context->thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;</div><div id="yui_3_16_0_ym19_1_1499806908743_2645">  }</div><div id="yui_3_16_0_ym19_1_1499806908743_2646"><br id="yui_3_16_0_ym19_1_1499806908743_2647"></div><div id="yui_3_16_0_ym19_1_1499806908743_2648"><br id="yui_3_16_0_ym19_1_1499806908743_2649"></div><div id="yui_3_16_0_ym19_1_1499806908743_2650"><br id="yui_3_16_0_ym19_1_1499806908743_2651"></div><div id="yui_3_16_0_ym19_1_1499806908743_2652">If I set the is-live property (  g_object_set (G_OBJECT (souphttpsource), "location", argv[1], "is-live", TRUE, NULL); )  then the decoder's latency is reduced, according to the lines above,</div><div id="yui_3_16_0_ym19_1_1499806908743_2653">BUT some latency is added on the souphttpsrc element. </div><div id="yui_3_16_0_ym19_1_1499806908743_2654"><br id="yui_3_16_0_ym19_1_1499806908743_2655"></div><div id="yui_3_16_0_ym19_1_1499806908743_2656">How can I avoid that? </div><div id="yui_3_16_0_ym19_1_1499806908743_2657"><br id="yui_3_16_0_ym19_1_1499806908743_2658"></div><div id="yui_3_16_0_ym19_1_1499806908743_2659">For now, the only solution I have is to HACK the code of gstavviddec.c and force ffmpegdec->context->thread_type = FF_THREAD_SLICE also in the case that is-live == FALSE (with the consequence that I don't get latency neither on the souphttpsrc neither on the avdec_h264 element)</div><div id="yui_3_16_0_ym19_1_1499806908743_2660">It seems to me something that should be fixed in the library, though...</div><div dir="ltr" id="yui_3_16_0_ym19_1_1499806908743_2661"><br id="yui_3_16_0_ym19_1_1499806908743_2662"></div></div></body></html>