The excellent ffmpeg is the swiss army knife of all video processing. Just as a reminder to myself, here's a command line to convert an image and audio file to a video.
ffmpeg -y -loop 1 -framerate 1 -i image.jpg -i Unknown.mp3 \ -c:v libx264 -preset medium -tune stillimage -crf 23 \ -vf scale=-1:720 -c:a copy -shortest -pix_fmt yuv420p \ -movflags +faststart output.mp4
The options are as follows:
- -y Yes, go ahead and overwrite output file. Useful when experimenting.
- -loop 1 Loop input stream 1. Makes the single image last forever as a stream.
- -framerate 1 Set video frame rate to 1FPS. This saves space. But going below 1 FPS causes compatibility issues with some players.
- -c:v libx264 Encode video as h.264 using the excellent x264 library. Good quality, great compatibility.
- -preset medium Use medium quality settings for video encoder. Other options: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow. No need to go overboard for still images.
- -tune stillimage Tune the video encoder for a still image.
- -crf 23 Video quality/bitrate. Values of 18 - 25 are reasonable. Lower values give higher quality and bitrates.
- -vf scale=-1:720 Scale the video image to 720 pixels of height, preserving aspect ration. Adjust to your needs.
- -c:a copy Copy the audio stream without re-encoding it.
- -shortest Finish encoding when the shortest input stream ends. Since we made the image stream infinite with -loop 1, the audio stream is the shortest.
- -pix_fmt yuv420p Use yuv pixel format for better compatibility.
- -movflags +faststart Arrange all the mp4 headers and stuff at the beginning of the file so that it can be streamed efficiently.
Optionally you may use
-c:a aac -b:a 192k instead of
-c:a copy to re-encode audio as AAC, which is more common in the mp4 container.
So there you go...