7

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
  • 121

2 Answers2

5

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
  • 121
0

option:

-reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_delay_max 4096

need to be put after -i option like below:

ffmpeg -i rtsp://rtspstreamaddress/1 -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_delay_max 4096 -fflags flush_packets -max_delay 2 -flags -global_header -hls_time 2 -hls_list_size 3 -vcodec copy -y /var/www/video.m3u8

bochs
  • 1