I'm working on a 24/7 music streaming channel. This script should stream the bg.mp4
on loop and play mp3 files from a folder called mp3
. Currently streaming the mp4 file on loop works but no audio is played.
Here is my current script:
ffmpeg -loglevel info -y -re \
-re -stream_loop -1 -i bg.mp4 \
-f concat -safe 0 -i <((for f in ./mp3/*.mp3; do path="$PWD/$f"; echo "file ${path@Q}"; done) | shuf) \
-c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k \
-framerate 25 -video_size 1280x720 -vf "format=yuv420p" -g 50 -shortest -strict experimental \
-c:a aac -b:a 128k -ar 44100 \
-f flv rtmp://a.rtmp.youtube.com/live2/
Running ffmpeg version 4.4.2-0ubuntu0.22.04.1
I'm relatively new to ffmpeg and any hints towards fixing this would be great.
My output logs: https://pastebin.com/aVbsWwgF
========= UPDATE =========
After a while of researching I finally got it working by using map: -map 0:v:0 -map 1:a:0
Final code:
ffmpeg -y -re \
-re -stream_loop -1 -i bg.mp4 \
-f concat -safe 0 -i <((for f in ./mp3/*.mp3; do path="$PWD/$f"; echo "file ${path@Q}"; done) | shuf) \
-c:v libx264 -preset veryfast -b:v 3000k -maxrate 3000k -bufsize 6000k \
-framerate 25 -video_size 1280x720 -vf "format=yuv420p" -g 50 -shortest -strict experimental \
-c:a aac -b:a 128k -ar 44100 -map 0:v:0 -map 1:a:0 \
-f flv rtmp://a.rtmp.youtube.com/live2/