<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font size="2">> </font>Does anyone know if key frames can be
found without decoding?</p>
<p>Yes, this how how I have been doing it to switch between 2 live
h264 encoded video sources (switch on Key-Frame):<br>
</p>
<div style="color: #d4d4d4;background-color: #1e1e1e;font-family: 'Droid Sans Mono', 'monospace', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #d4d4d4;"> </span><span style="color: #569cd6;">def</span><span style="color: #d4d4d4;"> </span><span style="color: #dcdcaa;">got_buff</span><span style="color: #d4d4d4;">(</span><span style="color: #9cdcfe;">self</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">pad</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">info</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">video_pad</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">audio_pad</span><span style="color: #d4d4d4;">):</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">buf</span><span style="color: #d4d4d4;"> = </span><span style="color: #9cdcfe;">info</span><span style="color: #d4d4d4;">.get_buffer()</span></div>
<div><span style="color: #d4d4d4;"> </span><span style="color: #dcdcaa;">print</span><span style="color: #d4d4d4;">(</span><span style="color: #ce9178;">"Waiting for Key-frame in pad '</span><span style="color: #569cd6;">{}</span><span style="color: #ce9178;">'..."</span><span style="color: #d4d4d4;">.</span><span style="color: #dcdcaa;">format</span><span style="color: #d4d4d4;">(</span><span style="color: #9cdcfe;">video_pad</span><span style="color: #d4d4d4;">))</span></div>
<div><span style="color: #d4d4d4;"> </span><span style="color: #c586c0;">if</span><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">buf</span><span style="color: #d4d4d4;">.has_flags(Gst.BufferFlags.DELTA_UNIT) </span><span style="color: #569cd6;">is</span><span style="color: #d4d4d4;"> </span><span style="color: #569cd6;">False</span><span style="color: #d4d4d4;">:</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #dcdcaa;">print</span><span style="color: #d4d4d4;">(</span><span style="color: #ce9178;">"Key-frame received in pad '</span><span style="color: #569cd6;">{}</span><span style="color: #ce9178;">'"</span><span style="color: #d4d4d4;">.</span><span style="color: #dcdcaa;">format</span><span style="color: #d4d4d4;">(</span><span style="color: #9cdcfe;">video_pad</span><span style="color: #d4d4d4;">))</span></div>
<div><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">self</span><span style="color: #d4d4d4;">.</span><span style="color: #9cdcfe;">video_selector</span><span style="color: #d4d4d4;">.set_property(</span><span style="color: #ce9178;">"listen-to"</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">video_pad</span><span style="color: #d4d4d4;">)</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">self</span><span style="color: #d4d4d4;">.</span><span style="color: #9cdcfe;">audio_selector</span><span style="color: #d4d4d4;">.set_property(</span><span style="color: #ce9178;">"listen-to"</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">audio_pad</span><span style="color: #d4d4d4;">)</span></div>
<div><span style="color: #d4d4d4;"> </span><span style="color: #c586c0;">return</span><span style="color: #d4d4d4;"> Gst.PadProbeReturn.REMOVE</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #c586c0;">else</span><span style="color: #d4d4d4;">:</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #c586c0;">return</span><span style="color: #d4d4d4;"> Gst.PadProbeReturn.OK</span></div>
<div><span style="color: #d4d4d4;"> </span><span style="color: #569cd6;">def</span><span style="color: #d4d4d4;"> </span><span style="color: #dcdcaa;">check_kf</span><span style="color: #d4d4d4;">(</span><span style="color: #9cdcfe;">self</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">video_pad</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">vsink</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">audio_pad</span><span style="color: #d4d4d4;">):</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #6a9955;"># add pad probe</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">vpad</span><span style="color: #d4d4d4;"> = </span><span style="color: #9cdcfe;">vsink</span><span style="color: #d4d4d4;">.get_static_pad(</span><span style="color: #ce9178;">"sink"</span><span style="color: #d4d4d4;">)</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #9cdcfe;">vpad</span><span style="color: #d4d4d4;">.add_probe(Gst.PadProbeType.BUFFER, </span><span style="color: #9cdcfe;">self</span><span style="color: #d4d4d4;">.</span><span style="color: #dcdcaa;">got_buff</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">video_pad</span><span style="color: #d4d4d4;">, </span><span style="color: #9cdcfe;">audio_pad</span><span style="color: #d4d4d4;">)</span></div>
<div><span style="color: #d4d4d4;"> </span><span style="color: #c586c0;">return</span><span style="color: #d4d4d4;"> </span><span style="color: #569cd6;">True</span></div></div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">
<div style="color: #d4d4d4;background-color: #1e1e1e;font-family: 'Droid Sans Mono', 'monospace', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #ce9178;">"udpsrc address=127.0.0.1 port=5000 ! application/x-rtp,media=video,payload=33,clock-rate=90000,encoding-name=MP2T ! rtpbin ! rtpmp2tdepay ! "</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #ce9178;">"tsdemux : h264parse ! "</span></div><div><span style="color: #d4d4d4;"> </span><span style="color: #ce9178;">"interpipesink name=cam1_V sync=false async=false "</span></div></div>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">And in some cases I have experienced
the flags missing unless I set the caps after 'h264parse' to
"video/x-h264,stream-format=byte-stream,alignment=au"<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Best Regards</div>
<div class="moz-cite-prefix">Marianna</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">On 31.05.2022 14.00,
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel-request@lists.freedesktop.org">gstreamer-devel-request@lists.freedesktop.org</a> wrote:<br>
</div>
<blockquote type="cite"
cite="mid:mailman.46.1653998403.4334.gstreamer-devel@lists.freedesktop.org">
<pre class="moz-quote-pre" wrap="">Hi
Does anyone know if key frames can be found without decoding? In the context of the pipeline rtspsrc->rtph264depay->h264parse->appsink, which element sets the GST_BUFFER_FLAG_DELTA_UNIT flag? I read that a keyframe has a unique start code in the NAL unit. In that case, does that mean rtph264depay sets the flag?
Thanks</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Best regards / Med venlig hilsen
“Marianna Smidth Buschle”</pre>
</body>
</html>