7

I'd like to add some images at the end of a mp4 file via ffmpeg:

enter image description here

Any help would be greatly appreciated.

2 Answers 2

7

Use this command:

ffmpeg -i "video" -loop 1 -t 3 -i "image" -f lavfi -t 3 -i anullsrc -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" output.mp4

Replace the t value with the duration that you want the image to stay. I've supplied the common encoding parameters. Replace those as needed.

For an image sequence, use

ffmpeg -i "video" -f image2 -framerate n -i "image" -f lavfi -t 3 -i aevalsrc=0 -filter_complex "[0:v] [0:a] [1:v] [2:a] concat=n=2:v=1:a=1 [v] [a]" -c:v libx264 -c:a aac -strict -2 -map "[v]" -map "[a]" output.mp4

Replace the n in framerate with the rate that you want.

4
  • Great work. Unfortunately doesn't work with audio-less videos. Could you add enough explanation to allow one to manipulate it to suit? Aug 15, 2019 at 21:38
  • As a modification to top answer, this is for working with videos with no audio by removing the [a] parts. ffmpeg.exe -i input.mp4 -loop 1 -t 3 -i d.png -f lavfi -t 3 -i anullsrc -filter_complex "[0:v] [1:v] concat=n=2:v=1 [v]" -c:v libx264 -strict -2 -map "[v]" output.mkv Note that for some reason ffmpeg will run forever when outputting to mp4 but works fine outputting to mkv. It's easy to then copy .mkv to .mp4 with ffmpeg -i output.mkv -codec copy output.mp4
    – allanw
    May 9, 2022 at 12:29
  • In the first command, where does the name of the image go? Feb 2, 2023 at 5:12
  • Substitute "image"
    – Gyan
    Feb 2, 2023 at 12:25
0

Refer to this command:

ffmpeg -y -i input.mp4 -loop 1 -framerate 25 -t 3 -i foo.jpg -t 3 -f lavfi -i aevalsrc=0 -i bar.png -filter_complex '[1:0]scale=640:480[curtain];[0:0][0:1][curtain][2:0] concat=n=2:v=1:a=1[out];[out][3:0]overlay=W-w-25:H-h-25' -max_muxing_queue_size 1000 output.mp4 -loglevel 'trace'

this will add an image at end of the mp4 ,and add watermake to the mp4.

1
  • 2
    Can you explain some of the options given to ffmpeg since readers may need to change them to fit their situation (for example, -framerate)? Why do you specify -loglevel 'trace'? That doesn't seem necessary for the command to complete properly. Jun 29, 2017 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.