user4875712
user4875712

Reputation:

Repeat last frame in video using ffmpeg

Hi i'm trying to concatenate few mp4 clips each of 2 secs length, created using drawtext filter, but before that I want to extend length of some of these by repeating the last frames.How can I do it?

Upvotes: 20

Views: 15068

Answers (1)

Gyan
Gyan

Reputation: 92928

With a build of ffmpeg newer than 2nd Nov 2018, you can use the below command :

ffmpeg -i in.mp4 -vf tpad=stop_mode=clone:stop_duration=2 out.mp4

Audio is ignored. For older versions, see below

The overlay filter, by default, repeats the last frame of the overlay input over the base input if the former has ended but the latter hasn't. So, the key is to overlay a truncated version of the main video over the full-length stream, thus "extending" the last frame. There's a different and simpler way to do the above:

ffmpeg -i in.mp4 -filter_complex "[0]trim=0:N[hold];[0][hold]concat[extended];[extended][0]overlay" out.mp4

Where N is the duration of the extension, in seconds.

Upvotes: 46

Related Questions