FFmpeg and stream editing with intro, preload videos -- 2

Job ID: 31117568

Budget: $30 – $250 USD

Hi, i got a streaming service where i got videos with rtmpdump command, send it to ffmpeg to optimize and publish to nginx to serve as hls to end users... Rtmpdump source sometimes fails and needs to be restarted, during that time ffmpeg stops sending data to nginx so end users player just gives errors and stops...

What i want to do be done is;
1- Start the stream with preload ad video and start waiting from rtmpdump command
2- When rtmpdump command responds successfully stop preload video and publish rtmpdump response
3- After a successfull start of rtmpdump, if it fails mid stream send a video like "source updating, please wait" and start retrying rtmpdump

Basically i want to make a continuous stream to prevent errors on endusers, right now i am using a bash script and it kinda works, sends the updating source please wait video but there is still couple of seconds down time while switching to it, i dont wont it like that. There is actually another website that uses same source with the way i am trying to describe, so i am pretty sure it can be done...

I am open to any kind of scripting language; it could be bash, it could be python, it could be anything... I just want it to work by creating minimal extra load then i am using right now... There will be about 60-70 active running streams so please consider that too...