FFMPEG version: 3.2.1-1 UBUNTU 16.04.1 Imagine, you have an mp3 audio file named wow.mp3 In that case, the following command will get the duration of the mp3 in seconds. ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 wow.mp3
Once you have the duration in seconds (imagine I got 11.36 seconds). Now since I have 3 images, I want to run each image for (11.36/3 = 3.79), then please use the following: ffmpeg -y -framerate 1/3.79 -start_number 1 -i ./swissGenevaLake_%d.jpg -i ./akib.mp3 -c:v libx264 -r 25 -pix_fmt yuv420p -c:a aac -strict experimental -shortest output.mp4
Here the images are ./swissGenevaLake_1.jpg, ./swissGenevaLake_2.jpg , and ./swissGenevaLake_3.jpg. -framerate 1/3.784 means, each image runs for 3.784 seconds. -start_number 1 means, starts with image number one, meaning ./swissGenevaLake_1.jpg -c:v libx264: video codec H.264 -r 25: output video framerate 25 -pix_fmt yuv420p: output video pixel format. -c:a aac: encode the audio using aac -shortest: end the video as soon as the audio is done. output.mp4: output file name Disclaimer: I have not tested merging images of multiple sizes. References: https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images https://trac.ffmpeg.org/wiki/Encode/AAC http://trac.ffmpeg.org/wiki/FFprobeTips | FFMPEG version: 3.2.1-1 UBUNTU 16.04.1 Imagine, you have an mp3 audio file named wow.mp3 In that case, the following command will get the duration of the mp3 in seconds. ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 wow.mp3
Once you have the duration in seconds (imagine I got 11.36 seconds). Now since I have 3 images, I want to run each image for (11.36/3 = 3.79), then please use the following: ffmpeg -y -framerate 1/3.79 -start_number 1 -i ./swissGenevaLake_%d.jpg -i ./akib.mp3 -c:v libx264 -r 25 -pix_fmt yuv420p -c:a aac -strict experimental -shortest output.mp4
Here the images are ./swissGenevaLake_1.jpg, ./swissGenevaLake_2.jpg, and ./swissGenevaLake_3.jpg. Meanings of the parts of the command: -y , overwrite the output file without asking -framerate 1/3.784 : each image runs for 3.784 seconds. -start_number 1 : starts with image number one, which in this case is ./swissGenevaLake_1.jpg -c:v libx264 : sets the output video codec to H.264 -r 25 : sets the output video framerate to 25 -pix_fmt yuv420p : sets the output video pixel format -c:a aac : encode the audio using aac -strict experimental : allows things that are experimental or nonstandard (more info here and here, for an example see this) -shortest : end the video as soon as the audio is done output.mp4 : output file name Disclaimer: I have not tested merging images of multiple sizes. References: https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images https://trac.ffmpeg.org/wiki/Encode/AAC http://trac.ffmpeg.org/wiki/FFprobeTips |