new

Try Stack Overflow for Business

Our new business plan for private Q&A offers single sign-on and advanced features. Get started by May 31 for 2 months free.

Learn more

Review|Suggested Edits

0
Rejected 16 hours ago:
greg-449 reviewed this 16 hours ago: Reject
This edit was intended to address the author of the post and makes no sense as an edit. It should have been written as a comment or an answer.
vinzee reviewed this 17 hours ago: Approve
dbrumann reviewed this yesterday: Reject
This edit defaces the post in order to promote a product or service, or is deliberately destructive.
(more)

7
votes
Comment: Better explanation of the parts of the command and links to documentation.

Join images and audio to result video

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

10 identical lines skipped
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 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.
Here the images are ./swissGenevaLake_1.jpg, ./swissGenevaLake_2.jpg, and ./swissGenevaLake_3.jpg. Meanings of the parts of the command:
-framerate 1/3.784 means, each image runs for 3.784 seconds.
`-y`, overwrite the output file without asking `-framerate 1/3.784`: each image runs for 3.784 seconds.
-start_number 1 means, starts with image number one, meaning ./swissGenevaLake_1.jpg
`-start_number 1`: starts with image number one, which in this case is ./swissGenevaLake_1.jpg
-c:v libx264: video codec H.264
`-c:v libx264`: sets the output video codec to H.264
-r 25: output video framerate 25
`-r 25`: sets the output video framerate to 25
-pix_fmt yuv420p: output video pixel format.
`-pix_fmt yuv420p`: sets the output video pixel format
-c:a aac: encode the audio using aac
`-c:a aac`: encode the audio using aac
-shortest: end the video as soon as the audio is done.
`-strict experimental`: allows things that are experimental or nonstandard (more info [here](https://ffmpeg.org/ffmpeg-codecs.html#Codec-Options) and [here](https://superuser.com/questions/543589/information-about-ffmpeg-command-line-options), for an example see [this](https://trac.ffmpeg.org/wiki/TheoraVorbisEncodingGuide)) `-shortest`: end the video as soon as the audio is done
output.mp4: output file name
`output.mp4`: output file name
Disclaimer: I have not tested merging images of multiple sizes. Disclaimer: I have not tested merging images of multiple sizes.
8 identical lines skipped