0

I use VLC to stream video to a remote server. Unfortunately, sometimes the connection is lost and I need to kill and restart VLC to make it work again.

The difficulty is that VLC does not return when the error occurs. It prints "error" on the terminal but continues running.

I would like to create a script that starts VLC, monitors its output and kill then restart it when "error" is displayed.

How to do so ?

Thanks

fdamien12
  • 43
  • 4
  • 1
    This may help you: https://stackoverflow.com/questions/157163/how-to-do-something-with-bash-when-a-text-line-appears-in-a-file – Marc Sances Apr 22 '21 at 14:34
  • How do you run VLC in the first place? – nino Apr 22 '21 at 17:46
  • I use the following command to transcode an incoming stream to a remote server : `cvlc -vvv http://my_incoming_stream --sout '#transcode{vcodec=h264,vb=1200,scale=Auto,width=640,height=480,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=rtmp,mux=ffmpeg{mux=flv},dst=rtmp://my_output_server}'` @MarcSances i've already seen your link but it uses a log file. I'd prefer use directly the terminal output, if possible. – fdamien12 Apr 23 '21 at 19:48
  • The question I sent you uses ``tail -f`` to read a log file, but any command output instead of ``tail -f`` should work the same. Do notice however that ``stderr`` will not be considered unless you type ``2>1`` before your pipe. – Marc Sances Apr 24 '21 at 16:41
  • Indeed, it works ! Thank you – fdamien12 Apr 25 '21 at 19:17

0 Answers0