Join Audio and Image -> Output as Video using FFmpeg

If you are in Windows, You can do it in Windows Movie maker too ... if you need instructions please leave a comment

For FFmpeg use this

ffmpeg -loop_input -vframes 14490 -i imagine.jpg -i audio.mp3 -y -r 30 
    -b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 result.mp4
  • vframes 14490 is the number of frames that should be looped in order to have a continuous image for the entire audio.mp3 file

    Ex: For 8 minutes and 3 seconds ((8m x 60s + 3s) x 30fps = 14490 vf)

Resource from here


There is a much simpler way than those suggested here, that doesn't require calculating the number of frames or inputting the length of individual files (especially better for batch processing). With a recent version of ffmpeg, you can use the -shortest option, which stops encoding when the shortest stream ends - in this case, input.mp3 (since the image will loop forever, it has infinite length):

ffmpeg -i input.mp3 -f image2 -loop 1 -r 2 -i input.jpg \
-shortest -c:a copy -c:v libx264 -crf 23 -preset veryfast output.mp4

This uses 2 frames per second for the image/video, which should be fine, but you can set it to a more standard 25 if you want.


subanki almost had it right. The working command line is as follows;

ffmpeg -y -loop 1 -i image.jpg -i audio.mp3 -r 30 -b:v 2500k -vframes 14490 -acodec libvo_aacenc -ab 160k result.mp4
-y

overwrite output files without prompting

-loop 1

The option ‘-loop_input’ is deprecated use -loop 1. See ffmpeg documentation.

-i

input file(s)

-r

Frames Per Second
Could also be expressed as: -r 30000/1001 giving a fps of 29.97nnn

-b:v

video bit rate; the higher the number, the better the quality and the larger the file size.

-vframes

As explained above; take the total time of your audio file in seconds (e.g. 00:02:41 (2 minutes 41 seconds) equals 161 total seconds (2 x 60) + 41). Then multiply the total seconds by the Frames Per Second that you specified with -r (e.g. 161 x 30 = 4830).

-vframes can be replaced with -t 161 (-t duration record or transcode “duration” seconds of audio/video)

-acodec

Use the correct audio codec for the type of file you are creating. For .mp4 it should be an AAC format. The codec libvo_aacenc was the correct encoding codec for my Windows 7 system.

-ab

audio bit rate

result.mp4

This is the name of the output file. It can be any legal file name for your system. The extension will help ffmpeg determin the proper video codec if you do not specify one using -vcodec.