4
I have two input files, a still image that's going to repeat itself as frames and an audio file.
How can I use the audio file without having to re-encode it to output an audio stream with the same format as the audio file?
4
I have two input files, a still image that's going to repeat itself as frames and an audio file.
How can I use the audio file without having to re-encode it to output an audio stream with the same format as the audio file?
7
The easiest would be:
ffmpeg -loop 1 -i image.jpg -i audio.m4a -c:v libx264 -c:a copy -shortest out.mp4
This will encode the image with x264 to an H.264 video stream and leave the audio stream untouched (by using the copy
encoder). The -shortest
option makes ffmpeg stop when the shortest input ends, i.e. the audio file.
Note that the audio stream determines the output formats available to you. If you have a PCM audio file (i.e. a .wav
of some sort), you cannot use MP4 containers. If you have MPEG-1 Layer III audio (MP3) or AAC audio (an .m4a
for example), the MP4 container will work. Check the Comparison of container formats to get an idea of what's possible.
See also: Create a video slideshow from images and the x264 Encoding Guide for tweaking the quality of the output.