Created
May 12, 2026 11:56
-
-
Save butteredbreadbox/36c6facde5d69611247afefac81bda4d to your computer and use it in GitHub Desktop.
FFmpeg command for a looping MP4 set to a folder of MP3s for YouTube (HLS)
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
| # "FILENAME.mp4" is where your video filename goes | |
| # "FOLDERNAME" is where your folder name goes for all your mp3s | |
| # "STREAMKEYHLS" is where your stream key goes | |
| # | |
| # uses HLS instead of RTMP | |
| # | |
| # 960x720@30 | |
| #!/bin/bash | |
| set -e | |
| while true | |
| do | |
| ffmpeg -loglevel info -y -re -stream_loop -1 \ | |
| -i FILENAME.mp4 \ | |
| -f concat -safe 0 -i <((for f in ./FOLDERNAME/*.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 -g 60 -pix_fmt yuv420p \ | |
| -c:a aac -b:a 128k -ar 44100 \ | |
| -map 0:v:0 -map 1:a:0 \ | |
| -hls_init_time 3 -hls_time 3 -master_pl_name master.m3u8 -http_persistent 1 -f hls -segment_wrap 1 -method POST "https://a.upload.youtube.com/http_upload_hls?cid=STREAMKEYHLS©=0&file=master.m3u8" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment