Creating video with audio and still image for YouTube

Here's what worked:

ffmpeg -i audio.mp3 -f image2 -loop 1 -i logo.jpg 
-r 15 -s 640x480 \
-c:v libx264 -crf 18 -tune stillimage -preset medium \
-shortest foo.mov

Specifically, the loop option, which will duplicate the image as frames. It will also then need the shortest option to keep the file from growing and growing (this way it truncates it to the length of the shortest stream – here, the audio file).

The r option changes the frame rate, and crf 18 sets the quality (use a higher value here for lower video quality). See here for more details: FFmpeg: The ultimate Video and Audio Manipulation Tool


A piece of code that works for me, from another forum:

ffmpeg -loop 1 -r ntsc -i image.jpg -i song.mp3 -c:a copy -c:v libx264 -preset fast -threads 0 -shortest output.mkv 

I took Pavel's code, that worked for me too, and shortened it by trimming needless options:

ffmpeg -loop 1 -shortest -i <audio file> -i <image file> <output video file>

this is a general form that works with any image and audio file as input and produce a video file as output.

That said, since your video stream will be made of a single picture repeated indefinitely, you could set a low frame rate (that is the number of images that appears in a second) with -r. Note that not all output containers allow low frame rates. One that does is avi, so you might do:

ffmpeg -loop 1 -shortest -r 0.1 -i <audio file> -i <image file> output.avi

this would create a video file with a frame rate of 0.1 (i.e. one image each 10 seconds) instead of the default of 25. This will affect file size but not video quality. Eventually, you can set the audio bitrate to get a better audio quality with -ab. This is the command I actually use to make this kind of videos for youtube:

ffmpeg -loop 1 -shortest -r 0.1 -i <audio file> -i <image file> -ab 128k output.avi

with avconv:

avconv -i input.mp3 -loop 1 -f image2 -i logo.png -r 30 -s 640x480 -ab 128k -ar 44100 -ac 1 -ss 00:00:00.000 -t 01:02:03.123 foo.ogv