A recipe to prepare audio file(s) for YouTube upload. Video will be a slideshow of images on repeat.
Requires: imagemagick ffmpeg
- Convert images to required size. Here I assume .png files and output to png/ folder. See http://www.imagemagick.org/Usage/crop/#extent
for f in *.png; do convert "$f" -resize 800x600 -gravity center -background black -extent 800x600 png/"$f".png; done
- Generate video out of pngs. Here each image is shown for 20 seconds. See https://trac.ffmpeg.org/wiki/Slideshow and https://en.wikibooks.org/wiki/FFMPEG_An_Intermediate_Guide/image_sequence#Filename_patterns
ffmpeg -framerate 1/20 -pattern_type glob -i "png/*.png" -c:v libx264 -vf "fps=25,format=yuv420p" png.mp4
- Concatenate audio files. See https://trac.ffmpeg.org/wiki/Concatenate
printf "file '%s'\n" ./*.flac > files.txt
ffmpeg -f concat -safe 0 -i files.txt files.flac
- Concatenate png video enough times to cover audio duration. See http://superuser.com/a/1116107/55867 for rationale.
for i in {1..10}; do printf "file '%s'\n" png.mp4 >> pngs.txt; done
ffmpeg -f concat -safe 0 -i pngs.txt -c copy pngs.mp4
- Create YouTube video using acceptable encoding settings. See https://www.virag.si/2015/06/encoding-videos-for-youtube-with-ffmpeg/
ffmpeg -i pngs.mp4 -i files.flac -shortest -codec:v libx264 -crf 21 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart youtube.mp4
- Generate a YouTube track listing to copy-paste in the video description.
youtube-playlist.sh *.flac
- Generate a video file with chapters.
youtube-chapters.sh *.flac > chapters
ffmpeg -i youtube.mp4 -i chapters -map_metadata 1 -codec copy youtube-chapters.mp4
Example output: https://www.youtube.com/watch?v=qjlDT819Q3s