Last active
May 12, 2026 11:56
-
-
Save butteredbreadbox/2a6251e5b8fdec933d7a57029d7db4a3 to your computer and use it in GitHub Desktop.
FFmpeg command for a looping MP4 set to a folder of MP3s for YouTube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # only tested with mp3s and mp4s. | |
| # code -stolen- taken from https://github.com/foxtacles/youtube-live-radio/blob/master/stream.sh | |
| # "VIDEO.mp4" is where your video filename goes | |
| # "MUSICFOLDER" is where your folder name goes for all your mp3s | |
| # "YOUTUBEKEY" is where your stream key goes | |
| # 960x720@30 | |
| #!/bin/bash | |
| set -e | |
| while true | |
| do | |
| ffmpeg -loglevel info -y -re -stream_loop -1 \ | |
| -i VIDEO.mp4 \ | |
| -f concat -safe 0 -i <((for f in ./MUSICFOLDER/*.mp3; do path="$PWD/$f"; echo "file ${path@Q}"; done) | shuf) \ | |
| -c:v libx264 -preset veryfast -b:v 4000k -maxrate 4000k -bufsize 6000k \ | |
| -vf scale=960:720 \ | |
| -r 30 -pix_fmt yuv420p \ | |
| -c:a aac -b:a 128k -ar 44100 \ | |
| -map 0:v:0 -map 1:a:0 \ | |
| -f flv rtmp://a.rtmp.youtube.com/live2/YOUTUBEKEY | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment