RTSP -> HLS using FFMPEG

6

2

I'm using FFMPEG to convert my rtsp stream into an HLS stream so it can be played on all browsers on my website using player js. I'm having an issue with FFMPEG dying if the internet connection to the rtsp stream goes out for a min. Is there a way to make it reconnect? I've tried using the -reconnect flag before the -i flag, but I got back that the command wasn't found.

ffmpeg -i rtsp://rtspstreamaddress/1 -fflags flush_packets -max_delay 2 -flags -global_header -hls_time 2 -hls_list_size 3 -vcodec copy -y /var/www/video.m3u8

I then have a website that uses playwerjs to show the live stream. How can I make sure that the stream stays up without having to manually log into the VPS and rerun the script.

James

Posted 2017-05-09T21:03:17.613

Reputation: 101

Have you looked at ffserver? It was designed for this sort of application. – Tyzoid – 2017-05-10T00:05:29.420

I have. But I don't think ffserver will help with reconnects. – James – 2017-05-10T03:18:07.623

Answers

4

I was able to create the following script that seems to be working for me. So far, it's been working for me.

!/bin/bash while : do ffmpeg -i rtsp://rtspstreamaddress/1 -fflags flush_packets -max_delay 2 -flags -global_header -hls_time 2 -hls_list_size 3 -vcodec copy -y /var/www/video.m3u8 done

James

Posted 2017-05-09T21:03:17.613

Reputation: 101