Reputation: 53
I have a Python application which uses GStreamer to live-stream video to the RTMP server.
The video is built with Compositor element from many types of source videos:
filesrc -> decodebin -> videoconvert -> imagefreeze -> capsfilter -> cairooverlay -> compositor
)webrtcbin -> h264parse -> avdec_h264 -> videoconvert -> videorate -> capsfilter -> videobox -> tee -> compositor
filesrc -> decodebin -> queue -> compositor
When I start the video it is somehow fast-fowarded to current pipeline time (for ex. clicking play after 8 seconds causes 30-second video to show only few frames of the first 8 seconds and then play normally).
I've managed to get running time for compositor but calling set_offset on any video bin pad makes video not playing at all (duration seems to be correct but there are only few frames of the whole video visible on the compositor).
Upvotes: 2
Views: 2180
Reputation: 53
After many attempts I've ended up with solution that uses input-selector
element and set_offset on the active sink pad. However, this can be only used for displaying full-screen video.
This code allowed me to play video from decodebin to running live-stream:
After loading file with decodebin (pad-added):
self.video_selector_pad = self.pipeline.output_video_selector.get_request_pad("sink_%u")
self.video_out_pad = self.video_queue.get_static_pad("src") # decodebin pad is linked to this queue
self.video_out_pad.use_fixed_caps()
self.video_out_pad.add_probe(Gst.PadProbeType.EVENT_DOWNSTREAM, self._on_video_downstream_event, None)
self.video_out_pad.set_active(False)
On play request by user:
compositor_running_time = self.pipeline.output_video_selector_compositor_pad.get_property("running-time")
self.video_out_pad.set_offset(compositor_running_time)
self.pipeline.output_video_selector.set_property("active-pad", self.video_selector_pad)
self.video_out_pad.set_active(True)
# send seek event as we want to play it from t = 0
seek_event = Gst.Event.new_seek(
1.0,
Gst.Format.TIME,
Gst.SeekFlags.FLUSH,
Gst.SeekType.SET,
0,
Gst.SeekType.NONE,
0
)
Upvotes: 1