We noticed that the orin hardware encoder does not react when Chrome sends NACK via webrtc to force sending back key unit events. When digging further we discussed with gstreamer maintainers and they told us that:
GStreamer’s RTP stack (rtpsession/rtpbin) will handle PLI (Picture Loss Indication) and FIR (Full Intra Refresh) requests from the receiver (Chrome browser) and convert them into GstForceKeyUnit events (Forcing keyframes). It is these force key unit events that an encoder is expected to handle. However, the nvv4l2*enc family of elements have never supported this interface and instead have a dedicated action signal ‘force-IDR’ for this purpose. webrtcsink (and many applications) contain a workaround for this: net/webrtc/src/webrtcsink/imp.rs · main · GStreamer / gst-plugins-rs · GitLab.
Can you please implement also handling this event name in the encoders closed source so we can only send those key frames only when needed (on lost packets)?
Hi,
We will check this but it may take some time. Since gst-v4l2 is public, would be great if you can check the source code and try to implement it. The source code is in
Ok, I’ve implemented the native event type, tested it and it works, most of the time. Is there any limitation of how many of those keyframes can we generate in a timeframe? I noticed that at first 2-4 events, the encoder does not respond, but then it works as expected.
Any concerns about this implementation or are you willing to include it upstream?
PS: do you think in sink_event makes sense to handle both upstream & downstream events or only downstream is ever possible there? Or we don’t need either implementation as GstVideoEncoder will already take care of handling a GstForceKeyUnit in either direction (both upstream and downstream)?
Hi,
Could you share why the check is added into if (frame->input_buffer)? Wonder if this may make multiple gst_v4l2_video_encoder_forceIDR() call for a single GstForceKeyUnit event.
We are using gst-launch-1.0 to verify that the gst_v4l2_video_enc_handle_frame function is taking effect.
However, we do not observe the gst_v4l2_video_enc_sink_event patch being triggered.
How do you ensure that the gst_v4l2_video_enc_sink_event patch is taking effect?
I also suspected that gst_v4l2_video_enc_sink_event part is not needed, but wanted your confirmation as well. My idea was that it would serve if user app land creates this custom event type manually, but you can remove this part if you consider fit.
the gst_v4l2_video_enc_handle_frame part is needed for the Chrome-webrtc Auto PLI event to work correctly out of the box without custom code, so that is what we would love to see integrated into the next release.
I am also aware that sending a force_IDR before streaming has started may result in a crash of the nvidia encoder to which not implementing the src_event handler would be much cleaner to implement.
The GstForceKeyUnit event can also contain an optional running time to queue up key frames in the future e.g. for HLS segmentation. Using the methods provided by GstVideoEncoder (through GstVideoCodecFrame) and not using a src_event handler make that scenario also become supported for free.