I have 1 image (jpg) and 1 audio file (MP3) and I would like to output this as a video file (say AVI for example).

Does anyone know how to use FFMPEG to join the two? I'd like to show the image for the duration of the audio.

Any ideas anyone?

  • Which Os are you using – subanki Sep 13 '10 at 9:00

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

  • Hi Subanki -- thanks for your comment!! I don't understand this though.. I need to output a video file from the audio and image. How does this do that? – user41559 Sep 13 '10 at 8:34
  • @nayrsllew I just found out that code doesn't work , sorry .. Well the basic thing is convert it to video using ffmpeg -f image2 -i image%d.jpg video.mpg then join video and audio – subanki Sep 13 '10 at 8:59
  • updated my answer , it was tough but my 1 hour google search found it , I am happy :) – subanki Sep 13 '10 at 9:20
  • The answer is correct , why the down -vote :( – subanki Sep 13 '10 at 16:54
  • Hi Cant do, can you help me here. The resulting video is too big. I need the video same size of mp3 file. My image file is very small. Also I need to upload this Video to Youtube. – Parminder Dec 1 '11 at 0:04

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

overwrite output files without prompting

-loop 1

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


input file(s)


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


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


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)


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.


audio bit rate


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.


That simple bash/cygwin script that AUTOMAGICALLY will encode all files of $AUDIO extension in directory to 10FPS mp4 video file in directory with folder.jpg image embedded,

useful for youtube uploads ;)

$'\n'; for a in `ls -1 *.$AUDIO `; do ffmpeg -i $a &2> $a.info ; done;
cat '' > do.sh
for a in `ls -1 *.$AUDIO`; do D=`grep Duration $a.info | cut -d',' -f1 | cut -d' ' -f4 | cut -d'.' -f1 | head -n1 `; S=$(( $( echo $D | cut -d':' -f2 ) * 60 + 1 + ` echo $D | cut -d':' -f3  ` )) ; echo ffmpeg -loop_input -vframes $(( $S * 10 )) -i folder.jpg -i \"$a\" -y  -r 10 -b 2500k -ab 384k -vcodec mpeg4 \"$a.mp4\" >> do.sh;  done;
split -l5 do.sh
xa* &

Download VirtualDub, then do this:

  1. Open the image like you would open a normal video file.

  2. Calculate the duration of the audio in seconds and round it up to the nearest whole second (e.g. 78.34 sec becomes 79 seconds). This value is called x from now on.

  3. Go to "video > frame rate" select "change to frame rate (fps)" and enter "1/x" as value. Additionally, if you want to have a normal frame rate in the resulting file like 25 fps, select "Convert to fps" and enter the wanted frame rate in there.

  4. Select "video > compression" and pick your favorite flavor. It can be that you need to adjust the size of the image with the resize filter.

  5. Go to "audio > audio from other file" and select your audio there. If needed select a compression for the audio.

  6. Save the file.

Source: stephanV

  • Thanks StephanV .. I need to use FFMpeg but this is a good suggestion.. thanks – user41559 Sep 13 '10 at 9:47

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.