S
S
sv22042016-01-17 02:37:25
fmpeg
sv2204, 2016-01-17 02:37:25

How to write a script to restart ffmpeg when the Internet is down?

Tell me the ffmpeg restart script for Ubuntu Server when the Internet breaks, here is 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 there is a short-term Internet interruption or some problems with the network, then ffmpeg freezes, and when you turn on the Internet, it hangs and does not resume encoding, but you need it to restart and continue its work
version of ffmpeg
ffmpeg version N-76944-g15206ff Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libdcadec --enable-libfreetype --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvo-aacenc --enable-libvidstab
libavutil      55.  9.100 / 55.  9.100
libavcodec     57. 16.101 / 57. 16.101
libavformat    57. 19.100 / 57. 19.100
libavdevice    57.  0.100 / 57.  0.100
libavfilter     6. 17.100 /  6. 17.100
libavresample   3.  0.  0 /  3.  0.  0
libswscale      4.  0.100 /  4.  0.100
libswresample   2.  0.101 /  2.  0.101
libpostproc    54.  0.100 / 54.  0.100

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
monah_tuk, 2016-01-19
@monah_tuk

First, try to use not the built-in RTMP module in FFmpeg, but build using librtmp (--enable-librtmp). They are functionally and in bugs are very different. If Ubuntu Server is based on 14.04 LTS, you can get it from my PPA: https ://launchpad.net/~adrozdoff/+archive/ubuntu/f...
what to do:
1. execute the command ulimit -c unlimited
2. run ffmpeg
3. wait for it to hang
4. execute the command from the adjacent console killall -ABRT ffmpeg
in the directory, a coredump file will be generated, which you can upload somewhere and see what happened there and why we are hanging.
In general, FFmpeg has such a problem when working with a network. At a minimum, I repaired the descriptor leak in the native implementation of rtmp. There might be something similar here. In addition, it is worth looking on their bug tracker for similar questions, they may already have a solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question