8

I'm cutting/converting some videos with ffmpeg. What I'd really like is to be able to have the output hold the last frame for a few seconds (with silence for audio). Is such a thing possible? Or will I have to somehow get the last frame and make a new video from that?

11

One method is to use the overlay video filter. Assuming your video is 640x480, 30 seconds duration, 25 frame rate:

ffmpeg -f lavfi -i nullsrc=s=640x480:d=35:r=25 -i video.mp4 -i audio.wav -filter_complex \
"[0:v][1:v]overlay[video]" -map "[video]" -map 2:a -codec:a copy -shortest output.mkv
  • I set the duration of the nullsrc source filter to be 5 seconds longer than input.mkv.

  • The default behavior of overlay is to repeat the last frame of the overlaid source. See the eof_action option for other behaviors.

  • The audio in this example is being stream copied (re-muxed) instead of being re-encoded.

  • The downside is that this examples requires re-encoding since a filter is being used, but it may be simpler than other methods since it is just one command.

  • That sounds great - but can I do it if I'm also replacing the audio stream with a wav file? Also, do I need to know the size of the source video? – xorsyst May 30 '14 at 8:43
  • 1
    @xorsyst Yes, you can replace the audio. I updated the example. Yes, this method requires that you know the frame size, duration, and frame rate of the source video, but all of these variables can be scripted. See FFprobe Tips. – llogan Jun 2 '14 at 17:47
0

I believe the answer to your question is "yes". I'm not super familiar with FFMPEG, but the easiest way I can see to accomplish your goal is to first extract the last frame to an image, make a video of a few seconds and then run an encode that concatenates the main video and your newly created video in one pass.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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