1

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?

1

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 image.jpg and 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

HELP FOR

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

  • Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material... – Donald Duck Mar 11 '17 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.