Prevent ffmpeg drop when dropped input icecast stream

0

I transcode an ICECAST stream and out it to udp multicast via ffmpeg with the following command:

ffmpeg -i http://ip:8000/icecast -vn -acodec libmp3lame -ar 44100 -ac 2 -ab 128 -f mpegts udp://ip:port

But if an icecast stream will be drop then ffmpeg drop also. Is the way keep ffmpeg running?
The best variant will be play silent in udp://ip:port stream when icecast stream droped and continue playing when this stream will be available again.
I routed output from wget and fIcy to ffmpeg, but no luck. Is exist any software solution for it?

Ivan Kolesnikov

Posted 2017-08-07T09:49:36.240

Reputation: 73

Answers

1

Not tested but worth a try

Shorter method

ffmpeg -reconnect_at_eof 1 -reconnect_streamed 1 -i http://ip:8000/icecast
       -vn -c:a libmp3lame -ar 44100 -ac 2 -ab 128 -f mpegts udp://ip:port

Longer method (try if above doesn't work)

ffmpeg -reconnect_at_eof 1 -reconnect_streamed 1 -i http://ip:8000/icecast
       -f lavfi -i anullsrc
       -filter_complex "[0]aresample=async=1[main];
                        [main][1]amix=dropout_transition=0,volume=2"
       -vn -c:a libmp3lame -ar 44100 -ac 2 -ab 128 -f mpegts udp://ip:port

Gyan

Posted 2017-08-07T09:49:36.240

Reputation: 21 016

Thank you! Very useful! Short method: reconnecting for about 4 seconds when the input stream is drop then ffmpeg drop also. I added -reconnect_delay_max 3600 parameter also, but it's not helped. Long method: As in the first method, reconnecting 4 seconds then writing silence, but not playing ICECAST stream when this stream running again. – Ivan Kolesnikov – 2017-08-07T12:42:14.650