Have a script that generates a rtmp stream that runs inside a screen using ffmpeg but this fails for some reason? If it run it directly in the command line it works so I tried to run it by opening > screen , running it and closing the screen with ctrl + d but even so it sometimes closes for reason.
Is there a way to log the stderr from ffmpeg inside the script to see why the command fails inside the script but works when run directly?
#!/bin/bash if [ "$1" = "run" ]; then source $HOME/.bash_aliases while [ 1 ]; do ffmpeg -f x11grab -s 1000x563 -framerate 30 -i $DISPLAY+10,151 -f pulse -ac 2 -i default -c:v libx264 -preset ultrafast -tune zerolatency -x264opts keyint=30:min-keyint=10 -b:v 2000k -pix_fmt yuv420p -s 1000x562 -c:a aac -b:a 160k -ar 44100 -t '4:00:00' -threads 0 -f flv rtmp://IPADDRESS:1935/live1/$CHANNEL done else killall -9 ffmpeg > /dev/null 2>&1 sleep 5s; screen -ls | grep ffmpeg > /dev/null 2>&1 if [ "$?" = "1" ]; then screen -mdS ffmpeg $0 run fi fi
Thank you ~