Why we can not stably save RTSP stream to file in ffmpeg?

I am working on a project and trying to save the RTSP stream in the file. But the following error stops the process :frowning:
video:331639kB audio:5199kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Non-monotonous DTS in output stream 0:1; previous: 5439375, current: 5439283; changing to 5439376. This may result in incorrect timestamps in the output file.Can anyone from the community please help me get rid of this error?

2 Likes

Hey! Can you please share the command you are using?
And please read this once: Overview of RTSP and RTMP

Hope this may help you!

1 Like

Sure, I am using the following command.
ffmpeg β€œrtsp://192.168.0.100:554/cam/realmonitor?channel=1&subtype=0” -c copy -f segment -segment_time 00:01:00 -reset_timestamps 1 -segment_format mkv -strftime 1 /home/user/.camera/recordings/2022/8/19/%H_%M_%S.mkv

1 Like

Saving an RTSP (Real Time Streaming Protocol) stream to a file using FFmpeg can be achieved using the FFmpeg command-line tool. Here is an example command that will save an RTSP stream to a file:

ffmpeg -i rtsp://<stream-url> -c copy output.mp4

This command will save the RTSP stream to a file called output.mp4 using the -c copy flag, which tells FFmpeg to copy the stream directly without re-encoding it.

1 Like

If you are having difficulty saving the RTSP stream to a file stably, there are a few things you can try:

Increase the timeout value using the timeout flag. This will allow ffmpeg more time to establish a connection to the stream before giving up.

For example:

ffmpeg -i rtsp://<stream-url> -c copy -timeout 60 output.mp4

  1. Try using a lower bitrate stream if available. This can help to reduce the load on the network and may improve stability.
  2. Make sure that you have a stable network connection. If the connection is unstable, this can cause problems when saving the stream to a file.
  3. Try using a different version of ffmpeg. It’s possible that a newer or older version of the tool may be more stable when saving RTSP streams to a file.

I hope this helps! Let me know if you have any other questions.

1 Like