How to Insert I-frame or Key-frame in x264enc

arpita banerjee reachtoarpi at gmail.com
Mon Jan 14 23:56:13 PST 2013


I have a server and a client application for video streaming. I have
used x264enc at server side for encoding.
I would like to insert a key-frame(IDR or I frame) when any packet
lost occurs in my video streaming application.
 I know there is an event GstForceKeyUnit to handle dynamic
key-frame/I-frame request. Could some one explain me what these
portion of code does in gstx264enc.c in gst-plugins-ugly-0.10.18 ??

if (gst_structure_has_name (s, "GstForceKeyUnit")) {
        /* Set I frame request */
        GST_OBJECT_LOCK (encoder);
        encoder->i_type = X264_TYPE_I;
        encoder->forcekeyunit_event = gst_event_copy (event);
        GST_EVENT_TYPE (encoder->forcekeyunit_event) =
            GST_EVENT_CUSTOM_DOWNSTREAM;
        GST_OBJECT_UNLOCK (encoder);
        forward = FALSE;
        gst_event_unref (event);
      }

If I create a custom upstream event in my server when any packet lost
occur and send this event to encoder the above code will work  or not
to insert key-frame??
Please explain someone.

Thanks in advance.


More information about the gstreamer-devel mailing list