How to switch element exactly on force key unit event

jmz jmzheng at
Tue Nov 21 03:34:07 UTC 2017


My pipeline looks like "tee ! queue ! filesink" where filesink will be
dynamically switched. I want to send EOS to the current filesink and start a
new filesink with a complete reference frame (i.e., SPS, PPS, and IFrame). I
use the following steps:

 1) Push upstream force-key-unit event to tee's sink pad.
 2) Install a GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM probe on queue's src pad.
 3) Inside the probe callback, if receiving force key unit event:
    3a) remove the probe first
    3b) push EOS to filesink's sink pad (is the filesink finalized
    3c) remove the current filesink from pipeline and add a new filesink to
    3d) return GST_PAD_PROBE_PASS (for passing downstream force-key-unit
event to the new filesink)
    Otherwise (i.e., not force key unit event), return GST_PAD_PROBE_PASS.

However, as I investigated the new sink file, the file starts with IFrame
instead of a complete reference frame. The SPS and PPS are shown with an
IFrame after several IDR frames and non-IDR frames.

Where do the other frames (appearing at the beginning of the new file) come
from? I block queue's src pad, switch filesink, and pass the force key unit
to the new filesink. The new file should start with the key unit.

Thanks for any help.

Sent from:

More information about the gstreamer-devel mailing list