-1

I have this nice one-liner to merge an image & sound and create a video:

ffmpeg -i AlbumCover.png -i AnglersTunnel.flac AnglersTunnel.flv

I have an entire folder filled with other sounds I want to process in the exact same way. How can I perform this one-liner on my entire folder? There is only 1 image file to use for every sound file. the output video file name should be the same as the audio file name.

My Folder

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
Ridalgo
  • 651
  • 1
  • 6
  • 10
  • You mentioned the folder with other sounds. What about the image file and the name of the output file? Is there a way to determine those based on the name of the sound file? For example, will the output video file always use the base name of the sound file with a different extension? – David Jan 02 '15 at 21:47
  • there is only 1 image file to use for every sound file. the output video file name should be the same as the audio file name. – Ridalgo Jan 02 '15 at 21:51
  • Ok - that's crucial. You should update your question with that info. – David Jan 02 '15 at 21:56
  • possible duplicate of [ffmpeg in a bash pipe](http://stackoverflow.com/questions/19606864/ffmpeg-in-a-bash-pipe) – shellter Jan 03 '15 at 01:29

1 Answers1

5
for i in *.flac; do
  ffmpeg -i AlbumCover.png -i "$i" "${i%%.*}.flv"
done
ZacWolf
  • 752
  • 5
  • 18
  • This is bash, not batch. – SomethingDark Jan 02 '15 at 22:19
  • this worked wonderful, except it only converted files without spaces. can you help? – Ridalgo Jan 02 '15 at 22:26
  • Oh dear, I just noticed the bash tag... @ThomasBuckler! The batch-file tag is _exclusively_ for Windows batch files! Now I've gone and downvoted a correct answer. Good. Job. – SomethingDark Jan 02 '15 at 22:29
  • I updated the answer. Try it with quotes around the filenames. – ZacWolf Jan 02 '15 at 22:40
  • Consider adding `-pix_fmt yuv420p` as an output option if the default encoder for FLV container format is libx264; otherwise a "better" but less compatible pixel format may be used. You can ignore this option if the crappy, old encoder named flv1 is used instead. – llogan Jan 03 '15 at 00:04
  • Also you should add `-loop 1` as an input option with `-shortest` as an output option. Without `-loop 1` the then video will contain a single frame which may not properly decode with some players. – llogan Jan 03 '15 at 00:35