Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG - Stream to RTMP output and save to MP4 at same time - with reconnect

Tags:

ffmpeg

rtmp

I'm trying to setup a pipeline where I can take an input and save to MP4 whilst at the same time streaming to an RTMP server.

So far I've been able to use a tee filter to achieve this and also using the onfail=ignore to make sure the pipeline stays up in the event of the RTMP/Recording failing.

Which is great!

However, I don't want the RTMP to just give up if it were to drop or be disconnected, I'd like it to keep attempting to reconnect and resume the stream.

I don't think FFMPEG has something like this, so I'd need to write it in a bash script or something that keeps restarting the process in the event of a drop.

I just have no idea how to achieve this!

Has anybody got any ideas or tackled this before?

Thanks,

Matt

like image 408
Matt Avatar asked Oct 20 '25 09:10

Matt


1 Answers

Use fifo format, which can reconnect.

My working example:

-f fifo -fifo_format flv \
-drop_pkts_on_overflow 1 -attempt_recovery 1 -recover_any_error 1 \
rtmp://bla.bla/bla
like image 56
Ipor Sircer Avatar answered Oct 22 '25 03:10

Ipor Sircer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!