How to convert MP3 to YouTube-allowed video format?
Solution 1:
There's some info about using FFmpeg to encode audio with a still image for YouTube, here, and some advice for doing bulk conversions in Windows, here.
As for encoding, I find that this works:
ffmpeg -loop 1 -r 1 -i pic.jpg -i audio.mp3 -c:a copy -shortest -c:v libx264 output.mp4
The -c:v libx264
encoding considerably reduces the output file size as mentioned at: https://superuser.com/a/1472572/128124
Solution 2:
You could also consider simple bash oneliner instead of python script -
for i in *.mp3; do ffmpeg -v quiet -i "picture.jpg" -i "$i" -shortest -acodec copy "`sed 's/mp3/mp4/g'<<<$i`"; done
This will convert all mp3 files in your current dir into mp4 videos with picture.jpg.
For converting flac to mp3 that would be
for i in *.flac; do ffmpeg -v quiet -i "$i" -ab 320k -ac 2 -ar 48000 "`sed 's/flac/mp3/g'<<<$i`"; done
Notice "-v quiet", which shuts ffmpeg's loud mouth and also double quotes around $i and sed
- this will ensure it won't fail with filenames containing spaces.
A tip: converting to video takes quite some time (at least for me). Try using -threads 4 (or any other value, of course. It won't make any sense on single-core cpu)
Edit: I've found out that "-loop 1" (suggested by others) creates loop (how surprising!) which is actually infinite. On my gentoo that means it will eat all your tasty bites. Without "-loop 1" it works just fine, so I suggest you to go with that.