I have a folder full of audio file with .mp3 .amr and .wav extension. I have a image.jpg. What I want is combine the image.jpg with every audio file in that folder and convert them to separate vidoe.mp4 file. How do I do it with FFmpge?
Here are two other answered questions that should help you achieve your goal.
"Combine one image + one audio file to make one video using FFmpeg" source: Combine one image + one audio file to make one video using FFmpeg
The order of options in the command line matters. The following works for my case:
ffmpeg -loop 1 -shortest -y -i image8.jpg -i sound11.amr -acodec copy -vcodec mjpeg result.avi
In a more general case, where
audio.wav are your input, you can use the following command, adapted from the FFmpeg wiki:
ffmpeg -loop 1 -i image.jpg -i audio.wav -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -pix_fmt yuv420p -shortest out.mp4
This would use the
libx264 encoder and provide you with better compression than the MJPEG codec used above. The audio is AAC, with the built-in
ffmpeg AAC encoder.
"How to do a for loop in windows command line?" source: https://stackoverflow.com/questions/11192039/how-to-do-a-for-loop-in-windows-command-line
The commandline interpreter does indeed have a FOR construct that you can use from the command prompt or from within a batch file.
For your purpose, you probably want something like:
FOR %i IN (*.ext) DO my-function %i
Which will result in the name of each file with extension *.ext in the current directory being passed to my-function (which could, for example, be another .bat file).
The (*.ext) part is the "filespec", and is pretty flexible with how you specify sets of files. For example, you could do:
FOR %i IN (C:\Some\Other\Dir\*.ext) DO my-function %i
To perform an operation in a different directory.
There are scores of options for the filespec and FOR in general. See
from the command prompt for more information.
Okay the content is now contained in the post itself thanks to a message from Donald Duck :D