<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p><br>
</p>
<p>I agree with Jeff Shanab, even if you got this working (all
frames as key-frames) it would be a bad solution encoding wise.</p>
<p><br>
</p>
<p>What you need to do is delay the input-selector switching until
you got a key-frame (only switch on key frames).</p>
<p>I have done something similar (though with simple RTP/UDP, not
rtspsrc) and can tell you it works fine.</p>
<p><br>
</p>
<p>There has been a similar entry on the mailing list about it about
a week ago: "Can you find key frame in h264 video without
decoding?"</p>
<p>But here is a snippet from my source code demonstrating the
principle (note that I have used interpipesrc/sink instead of
input-selector, but should be pretty similar):<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>
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"
<p><br>
</p>
<p>Best Regards</p>
<p>Marianna</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 04.06.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.39.1654344002.15887.gstreamer-devel@lists.freedesktop.org">
<pre class="moz-quote-pre" wrap="">err I frame set to 1 do you mean gop size 1, no difference frames? or do
you mean once a second.
All I frames will be only slightly better than JPEG on bandwidth and would
make things worse.
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Best regards / Med venlig hilsen
“Marianna Smidth Buschle”</pre>
</body>
</html>