How to switch element exactly on force key unit event
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.
Re: How to switch element exactly on force key unit event
> Where do the other frames (appearing at the beginning of the new file)
> from? I block queue's src pad, switch filesink, and pass the force key
> to the new filesink. The new file should start with the key unit.
I found the reason that the new file does not contain SPS and PPS at the
beginning of file. I have pipeline as "h264parse ! mpegtsmux ! tee ! queue !
multifilesink." To switch multifilesink, an upstream force-key-unit event
(set running_time to to GST_CLOCK_TIME_NONE) is pushed to tee's sink pad
[step 1]. Both mpegtsmux and h264parse receive the event. If mpegtsmux
pushes a downstream force-key-unit event before h264parse does (is this
always?), only keyframe comes along with the event. This is why the new file
is created with no SPS and PPS upon receiving the downstream event [step
If I send the upstream force-key-unit event to only h264parse, the h264parse
will send downstream force-key-unit event along with SPS, PPS, and keyframe.
However, the mpegtsmux does not push the downstream force-key-unit event
because it has queued that a new key unit should be produced at a specific
time. This is mpegtsmux_sink_event() reports "skipping downstream force key
unit event as an upstream force key unit is already queued"
Shall I send the upstream force-key-unit event to only h264parse or both
h264parse and mpegtsmux? If only h264parse, can we let an element
(mpegtsmux) push a downstream event even if it has queued an upstream force
Hope my question is described clearly and someone would give me a hand.