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 -y -i image8.jpg -i sound11.amr -shortest -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 -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.


Even easier:

ffmpeg -i ep1.png -i ep1.wav ep1.flv

FFmpeg will try to pick the best codec automatically, depending on the extension of your output file.

Update: I noticed YouTube has difficulty processing the video (gets stuck at 95%) I think because there's only one frame. The solution I found to make YouTube happy: add more frames. Also, I added-acodec copy to preserve the audio quality. You need -shortest or it loops forever. (It stops at the end of the shortest stream, which is the audio, because the image loop is infinite.) The order of your options is very important for speed, as filters (and such) are processed in the order you specify. If you change the order of these parameters, the results are dramatically different.

ffmpeg -r 1 -loop 1 -i ep1.jpg -i ep1.wav -acodec copy -r 1 -shortest -vf scale=1280:720 ep1.flv

Also notice that I set the frame rate twice, that's not an accident--the first frame rate is for the input, second is for the output. If you do this correctly, there should only be one frame per second of video, which means it encodes relatively fast. Also I set the resolution to 720p here, which means you should get HD audio on YouTube :-)