Saving RTSP stream to MP4 no duration and not seekable

Hello,

I’m trying to save an RTSP stream (at a certain key frame) to a mp4 file so I drop first few frames and key frame; the issue I’m running into is my resultant mp4 file does not have a duration and is not seekable. This seems to be because the rtsp camera somehow has caps framerate=(string)0/1 which means FPS isn’t set.

Here is my setup:
pipeline 1: rtspsrc ! … ! h264depay ! h264parse ! appsink
pipeline 2: appsrc ! … ! h264parse ! mp4mux ! filesink

so essentially appsink is handing over GstSamples to appsrc starting at a key frame and appsrc pipeline is saving the frames to file.

interestingly, if I run gst-launch-1.0 -e rtspsrc ! … ! h264parse ! mp4mux ! filesink then despite the caps of framerate=0/1 the resultant mp4 file has duration and is seekable. I did notice in logs a-framerate=30.0 before framerate=0/1 in caps eventually.

How can I ensure my mp4 file has duration and is seekable?

Thank you very much!

Try sending EOS event on second pipeline and wait for EOS message in your application.

Thanks, I already do that through gst_app_src_end_of_stream(appsrc) and I see GST_MESSAGE_EOS on gst_bus_timed_pop_filtered(). I’m only seeing this issue with rtsp camera that has framerate=0/1 (if I try different camera that has framerate=30/1 then it all works find).