GStreamer dynamic recording pipeline with valve element
I have a gstreamer pipeline that does some processing on stream and based on this processing it generates recording event to another GStreamer recording pipeline on a tee branch.
The whole pipeline is as the following:
rtsp-source-> h264-depay -> tee-> h264-parser -> decoder ->some-processing-plugin
|-> h264-parser -> recordbin
recordbin
is my recording pipeline and it is as the following:
valve-> queue-> avimux-> filesink
I have start and stop functions this is the important part of my start function where I set a new file location in the filesink and start the recording pipeline:
gst_element_set_locked_state(filesink,TRUE);
gst_element_set_state(filesink,GST_STATE_NULL);
g_object_set(G_OBJECT(filesink), "location", fileName, NULL);
g_object_set(G_OBJECT(pre_muxer_valve), "drop", FALSE, NULL);
g_print("After opening pre queue valve\n");
gst_element_set_state(filesink,GST_STATE_PLAYING);
gst_element_set_locked_state(filesink,FALSE);
gst_element_sync_state_with_parent(filesink);
and this is a part of my stop function where I am stop the recording after some amount of time:
g_object_set(G_OBJECT(pre_muxer_valve), "drop", TRUE, NULL);
g_print("Recording stopped\n");
gst_element_send_event(muxer,gst_event_new_eos());
gst_element_send_event(muxer,gst_event_new_flush_stop(TRUE));
I know that I need to send EOS
event to the muxer
and the filesink
to close the file correctly and get a playable file. My problem is after first time I call the stop function if I sent EOS
event only on the next start when I open the valve
the pipeline immediately receive an EOS
and stops if I send an EOS
then a FLUSH_STOP
event I get the following message and all the output files is 0 bytes not corrupted it doesn't contain any data as if the filesink
didn't write any thing in the file but the pipeline doesn't stop:
(recording-test:30341): GStreamer-CRITICAL **: 16:22:10.433: gst_segment_to_running_time: assertion 'segment->format == format' failed
any help would be appreciated.