I know this question has been asked infinite times, but it has not been answered with a decent answer infinite times as well.

How to make ffmpeg keep working even if source becomes unavailable? VLC waits until connection comes back again, why ffmepg does not have such functionality?

I have tried with:

-reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 4962 -timeout 2000000000

but none works as expected. FFmpeg quits after only few seconds. I don't want to restart ffmpeg if connection interrupts because I need output HLS fragments to be available. Restarting ffmpeg makes fragments to be overwritten from the beginning.


3 Answers 3


FFmpeg command line arguments are position sensitive, so maybe you are not adding them in the right position. Try to put those options before the input. Example:

ffmpeg -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2 -i input -c:v copy -c:a copy outputfile.m3u8

'reconnect_delay_max' range is [0 - 4294]

It worked for me.

  • I already use reconnecting parameters before the input URL. FFmpeg version is the latest. Mar 9, 2016 at 9:29
  • I'm also using the latest version of ffmpeg in your option the 'reconnect_delay_max value need to be between [0 - 4294] yours is 4962 try with a lower value
    – slim tabka
    Mar 9, 2016 at 9:47
  • Ok even with 4294 it makes no difference. Once the HTTP source is down it quits with: [http @ 0x1f986c0] Will reconnect at 26390596 error=Success. [http @ 0x1f986c0] Will reconnect at 0 error=Success. Last message repeated 2 times Mar 9, 2016 at 9:54
  • 1
    None of these options exist anymore.
    – Ken Sharp
    Dec 24, 2020 at 15:34
  • 1
    @KenSharp these reconnect options are only available for http inputs.
    – Muhammad
    May 26, 2022 at 22:47

FFmpeg DOES NOT reconnect if the interruption lasts more than 4 seconds. When network session is lost ffmpeg quits.

The reason for this is that apparently the variable holding the maximum reconnect is 32-bits in size and contains a number which it divides by 1,000,000 to get a millisecond count. Hence the maximum wait is 2^32 / 1000000 = 4294.9673 milliseconds or 4.294 seconds.

  • 3
    This is not always true. Ffmpeg will stall sometimes, output halted, connection closed but the proccess is still alive. Try to suspend and resume connection. For me it happens also if the server i am connecting to is stalling for some reason, connection closed in log, but process is alive.
    – mjs
    Apr 3, 2016 at 9:56
  • Not always true, sometimes? Is your theory reproducible? Jan 11, 2018 at 18:06
  • This was a long time ago, but with poor connections it will still happen, yes, I believe. Difficult to reproduce unless the right circumstances are there.
    – mjs
    Jan 29, 2018 at 17:59
  • The timeout parameter is expressed in seconds. Nov 6 at 16:51

I have solution for connection down for TCP issues! Just add option timeout ( in microseconds )

ffmpeg -timeout 10000000 \
-i rtsp://input_ip/h264 \
-c copy \
-f flv rtmp://output_ip
  • Set socket TCP I/O timeout in microseconds. It's not clear how this will help.
    – Ken Sharp
    May 24, 2020 at 17:35
  • The timeout is expressed in seconds. Nov 6 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .