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.
I also found that adding
– Ciro Santilli 新疆改造中心法轮功六四事件 – 2019-08-20T09:16:49.587-vcodec libx264
drastically reduces the video size increase relative to the MP3: https://superuser.com/a/1472572/128124@CiroSantill Yes, that's a much better solution. I updated the answer. – slhck – 2019-08-21T09:29:59.503
@slhck thanks for confirming! I edited to also add a link to my answer as attribution :-) – Ciro Santilli 新疆改造中心法轮功六四事件 – 2019-08-21T09:33:11.250