function api() { curl -sS http://10.5.5.9/$1 -o$2 } # Make sure we're on the GoPro wifi nmcli c s --active | grep GoPro > /dev/null if [ $? -eq 1 ] then echo "Error: not connected to GoPro" exit 1 fi # Create the video device and delete it on script exit DEVICE=$(v4l2loopback-ctl add -n "GoPro") function rmdevice() { v4l2loopback-ctl delete $DEVICE } trap rmdevice EXIT # Make sure preview is on PASSWORD=$(api bacpac/sd - | strings) api "camera/pv?t=$PASSWORD&p=%02" /dev/null ffmpeg -hide_banner -loglevel error -stats -i "http://10.5.5.9:8080/live/amba.m3u8" -vf format=yuv420p -f v4l2 $DEVICE