user15180344
user15180344

Reputation: 60

How to extend a video by freezing the last frame without reencoding the whole stream?

I'd like to achieve two things without re-encoding the whole video stream:

  1. Extend a video by freezing the last frame for a given duration.
  2. Extend a video by freezing a frame at a given timestamp for a given duration.

Currently I'm using ffmpeg -i in.mp4 -vf tpad=stop_mode=clone:stop_duration=5 out.mp4 but it requires encoding the whole video stream and only allows freezing the last frame of the stream. To get my desired result I need to split the video into segments, extract the last second of a segment to a separate file (so I re-encode just that part), run the above command on it and then merge all the segments back with concat demuxer.

Is there any better and simpler way to achieve the above?

Upvotes: 3

Views: 3055

Answers (1)

Gyan
Gyan

Reputation: 93028

To 'extend' the the last frame, extend the audio stream by padding it.

ffmpeg -i in.mp4 -c:v copy -af apad -t 5 out.mp4

If there's no existing audio stream, add one

ffmpeg -i in.mp4 -f lavfi -i anullsrc -c:v copy -af apad -t 5 out.mp4

For pausing a frame in the middle with minimal re-encoding , segmenting + concat is indeed the way to go

Upvotes: 3

Related Questions