Unable to save RTSP stream to file

Getting errors while saving the RTSP stream from the camera to the file.
video:331639kB audio:5199kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Hi Henry!
I also faced the same problem in the past and resolved this by adjusting the buffer size used by ffmpeg.
You can do this by adding the -rtsp_transport tcp option to your command, which will cause ffmpeg to use TCP to receive the stream, rather than UDP.
This can help to improve the stability of the stream by reducing packet loss.

Another option is to use the -stimeout option to set a timeout for the initial connection to the RTSP stream. This can help to prevent ffmpeg from hanging if the initial connection to the stream takes too long.

Can you please write the sample command for more elaboration?

Sure, here it is:
ffmpeg -rtsp_transport tcp -stimeout 10000000 -reconnect 1 -i rtsp://:@/ -b:v 1024k -c:v copy output.mp4
You can also try setting a higher value for the “-reconnect” option, which will cause ffmpeg to automatically reconnect to the stream if the connection is lost.

I tried but the stream is still unstable! :frowning:

Try to lower the -b option to reduce the bitrate of the output file, this can avoid congestion in the network and allow the stream to be saved stable.

You can play around with different values for these options to see which ones work best for your specific use case.

1 Like