tee and filesink does not work if stream is interrupted
clydemcqueen opened this issue · comments
It would be nice to add a tee to the configuration and write the stream to a file while also generating ROS images. When tested with live streams (camera or udpsrc) the ROS images are generated correctly but the resulting mp4 file will not open. I suspect the problem is that the file is not closed correctly when the node is shut down.
This gst-launch-1.0 command works correctly -- note the "-e" option, which generates an EOS event before shutting down the pipeline:
gst-launch-1.0 -e -v v4l2src device=/dev/video1 do-timestamp=true ! queue ! video/x-h264,width=1920,height=1080,framerate=30/1 ! h264parse ! tee name=fork ! queue ! mp4mux ! filesink location=save.mp4 fork. ! queue ! avdec_h264 ! autovideosink
This similar gscam2 configuration doesn't generate a usable file:
v4l2src device=/dev/video1 do-timestamp=true ! queue ! video/x-h264,width=1920,height=1080,framerate=30/1 ! h264parse ! tee name=fork ! queue ! mp4mux ! filesink location=save.mp4 fork. ! avdec_h264 ! videoconvert
Related to #3
A possible workaround is to use splitmuxsink
instead of filesink
, this will correctly close all but the last file. Example:
GSCAM_CONFIG="v4l2src device=/dev/video1 do-timestamp=true ! queue ! video/x-h264,width=1920,height=1080,framerate=30/1 ! h264parse ! tee name=fork ! queue ! splitmuxsink location=video%02d.mov max-size-bytes=10000000 fork. ! avdec_h264 ! videoconvert"
The correct fix here is to send an EOS into the pipeline (gst_element_send_event(pipe, gst_event_new_eos())
) and continue processing until the EOS message is received on the bus (or a timeout, just in case)