How to force keyframes using Python GST bindings

Gary Metalle Gary.Metalle at
Fri Nov 6 09:02:33 UTC 2020


I'm not sure about the Python bindings but it's very easy to force the encoder to knock out a keyframe when you want:

	GstPad *encoder_src_pad = gst_element_get_static_pad(st->streamer.encoder, "src");
	if (encoder_src_pad) {
		gst_pad_send_event(encoder_src_pad, gst_event_new_custom(GST_EVENT_CUSTOM_UPSTREAM,
			gst_structure_new("GstForceKeyUnit", "all-headers",G_TYPE_BOOLEAN, TRUE, NULL)));

Note in my example the 'st->streamer.encoder' is the pointer to the GstElement that is the h264 encoder.

From: gstreamer-devel <gstreamer-devel-bounces at> on behalf of Moiz <moiz at>
Sent: 06 November 2020 01:25
To: gstreamer-devel at
Subject: How to force keyframes using Python GST bindings

Hello, I am building my gstreamer pipeline to encode h264, and send rtp
packets over udp.

Ideally I can request a keyframe when packets are lost, I am not exactly
sure how I would do this.

I am thinking I can setup a small http server to listen for packets lost,
and am wondering if there is any gst function I can run to force a keyframe.

I have come across this article

However, I am not sure as this forcing keyframe action can be implemented
using the python gst bindings.

Is this possible, if so how can I go about it?

Sent from:
gstreamer-devel mailing list
gstreamer-devel at

More information about the gstreamer-devel mailing list