I have volunteered to do livestream at a conf. The plan goes like obs-> nginx rtmp (on a vm on a vps)-> youtube cause we wanted to have a fallback mechanism where when obs fails a fallback.mp4 sended to youtube by ffmpeg on a loop until obs gets back. so that
the user can have a seamless experience. i have pulled off the nginx setup, both on local and docker but i can’t pull off the fallback mechanism. please take a look at my config:
ngnix.conf
worker_processes auto;
events {
worker_connections 1024;
}
rtmp {
access_log /var/log/nginx/rtmp_access.log;
server {
listen 1935;
application live {
live on;
exec_publish /bin/bash /scripts/stop-fallback.sh;
exec_publish_done /bin/bash /scripts/start-fallback.sh;
push rtmp://a.rtmp.youtube.com/live2/stream_key;
}
}
}
start-fallback.sh
#!/bin/bash
echo "$(date): start-fallback.sh called" >> /tmp/fallback.log
FALLBACK_VIDEO="/videos/fallback.mp4"
RTMP_URL="rtmp://localhost/out/fallback"
/usr/bin/ffmpeg -re -stream_loop -1 -i "$FALLBACK_VIDEO" -c:v libx264 -c:a aac -f flv "$RTMP_URL" &
echo $! > /tmp/fallback.pid
echo "$(date): fallback ffmpeg started with PID $(cat /tmp/fallback.pid)" >> /tmp/fallback.log
stop-fallback.sh
#!/bin/bash
echo "$(date): stop-fallback.sh called" >> /tmp/fallback.log
if [ -f /tmp/fallback.pid ]; then
kill $(cat /tmp/fallback.pid) && rm /tmp/fallback.pid
echo "$(date): fallback ffmpeg stopped" >> /tmp/fallback.log
else
echo "$(date): no fallback pid found" >> /tmp/fallback.log
fi
Ive tried all sorts of things, even tried replacing start-fallback.sh with echo "test" > brr brr did not get created. ive manually ran the scripts. its working fine, also stream successfully reaches youtube, but exec_publish and exec_publish_done never worked. i just want to get it to work. ive tried docs, ai, friends, so if you can help me, please