Tell the ffmpeg restart script when the Internet is broken, here’s the launch line:

ffmpeg -analyzeduration 0 -i входной поток -c:v libx264 -deinterlace -timecode 01:02:03:04 -s 500x300 -r 25 -vb 220k -profile:v baseline -preset:v superfast -tune zerolatency -c:a libmp3lame -b:a 11k -ac 2 -ar 11025 -f flv "rtmp://выходной поток flashver=FMLE/3.0\20(compatible;\20FMSc/1.0) authmod=llnw live=1 playpath=" 

If a short-term Internet breakdown occurs or there are some problems with the network, ffmpeg hangs, and when you turn on the Internet, it still hangs and does not resume coding, but you need to restart it and continue its work

  • Do you accidentally use it in conjunction with nginx? - gbg
  • No, nginx is not there, but if there is a solution with it, I will install it - Stas
  • Well, I see that the flow in your rtmp goes. This means that there must be a transcription server. What is your server? - gbg
  • the stream goes to a third-party media server, and I launch ffmpeg on Ubuntu - Stas
  • and when falling, ffmpeg falls? - gbg

2 answers 2

Ffmpeg has a great hangover hangover. I would try my luck with gstreamer to begin with.

It supports all the necessary fragments of the pipeline, so experimenting, you can pick up some good parameters.

  • Thanks, but for now this is not an option, you need to look for a solution for ffmpeg - Stas

Alas, for this scenario, FFMPEG is the most unstable tool, there are alternative solutions to circumvent the problem with the Internet cliff:

A rude option: wrap your ffmpeg into a bash script and monitor the Internet status with a separate script (simple extra ping every 5-10 seconds), in case of a break, kill (restart) the script and start again as soon as the Internet resumes. And the network breakage factor is still unclear: as far as I understand, problems arise on the side of the streamer, i.e., from where you are trying to start ffmpeg, and the “ input stream ” is pulled from the same server.

The correct and more fault-tolerant option is to use the Gstreamer package mentioned by the user @gbg, since the package uses pipeline methods and creates a kind of listener socket. It will be enough to install gst-plugins-bad, gst-plugins-good, gst-plugins-base plugins.