Answers.Body: <p>One method is to use the <a href="http://ffmpeg.org/ffmpeg-filters.html#overlay" rel="noreferrer"><code>overlay</code> video filter</a>. Assuming your video is 640x480, 30 seconds duration, 25 frame rate:</p>
  
  <pre><code>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
  </code></pre>
  
  <ul>
  <li><p>I set the duration of the <a href="http://ffmpeg.org/ffmpeg-filters.html#color_002c-haldclutsrc_002c-nullsrc_002c-rgbtestsrc_002c-smptebars_002c-smptehdbars_002c-testsrc" rel="noreferrer"><code>nullsrc</code> source filter</a> to be 5 seconds longer than <code>input.mkv</code>.</p></li>
  <li><p>The default behavior of overlay is to repeat the last frame of the overlaid source. See the <code>eof_action</code> option for other behaviors. </p></li>
  <li><p>The audio in this example is being <a href="http://ffmpeg.org/ffmpeg.html#Stream-copy" rel="noreferrer">stream copied</a> (re-muxed) instead of being re-encoded.</p></li>
  <li><p>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.</p></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-30T08:43:46.693Z
Answers.Text: 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?
Answers.UserDisplayName: xorsyst
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-02T17:47:58.743Z
Answers.Text: @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](https://trac.ffmpeg.org/wiki/FFprobeTips).
Answers.UserDisplayName: llogan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-28T18:43:58.277Z
Answers.LastActivityDate: 2015-06-13T14:27:07.830Z
Answers.LastEditDate: 2015-06-13T14:27:07.830Z
Answers.UserDisplayName: llogan
Answers.Body: <p>This solution is much faster because it does not require re-encoding.</p>
  <p>If there already is an existing audio stream:</p>
  <pre><code>ffmpeg -i in.mp4 -vcodec copy -af apad -t 60 out.mp4
  </code></pre>
  <p>If there is NO existing audio stream:</p>
  <pre><code>ffmpeg -i in.mp4 -f lavfi -i anullsrc -vcodec copy -af apad -t 60 out.mp4
  </code></pre>
  <ul>
  <li><p>Note that the <code>-t 60</code> refers to the length in seconds of the final output, not the seconds to extend it by.</p>
  </li>
  <li><p>The reason this works is because when the video and audio are different lengths, ffmpeg will extend the shorter stream to match the longer one by default (unless you use the <code>-shortest</code> option).</p>
  </li>
  </ul>
  <p>(<a href="https://stackoverflow.com/questions/66197914/how-to-extend-a-video-by-freezing-the-last-frame-without-reencoding-the-whole-st/66202619#66202619">credit Gyan</a>)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-08T18:26:37.953Z
Answers.Text: Great solution - Now if I could only also apply a fade-out to the audio this would be perfect.
Answers.UserDisplayName: xorsyst
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-09T00:30:22.700Z
Answers.LastActivityDate: 2023-06-09T00:30:22.700Z
Answers.UserDisplayName: wisbucky
Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-05-28T14:32:03.677Z
Answers.LastActivityDate: 2014-05-28T14:32:03.677Z
Answers.UserDisplayName: AJ Henderson
Answers.Body: <p>The currently accepted answer is from 2014. The more recently added <a href="https://ffmpeg.org/ffmpeg-filters.html#tpad" rel="noreferrer"><code>tpad</code></a> filter lets you do this more easily.</p>
  <pre><code>ffmpeg -i in.mp4 -vf tpad=stop_mode=clone:stop_duration=2 out.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-09T00:31:10.633Z
Answers.Text: This solution can be slow since it re-encodes the video. This solution is much faster: https://video.stackexchange.com/questions/10825/how-to-hold-the-last-frame-when-using-ffmpeg/36571#36571
Answers.UserDisplayName: wisbucky
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-03T19:27:06.417Z
Answers.LastActivityDate: 2021-09-14T17:36:28.900Z
Answers.LastEditDate: 2021-09-14T17:36:28.900Z
Answers.UserDisplayName: Stephen Hart
Body: <p>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?</p>
  
Tags: <ffmpeg>
Title: How to hold the last frame when using ffmpeg
UserDisplayName: xorsyst
ThreadText: # How to hold the last frame when using ffmpeg
  
  (Asked by: username_0 on 2014-05-28)
  
  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?
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_4 on 2021-04-03. Score: 13 | Accepted answer
  
  The currently accepted answer is from 2014. The more recently added [`tpad`](https://ffmpeg.org/ffmpeg-filters.html#tpad) filter lets you do this more easily.
  
  ```
  ffmpeg -i in.mp4 -vf tpad=stop_mode=clone:stop_duration=2 out.mp4
  
  ```
  
  > **Comments:**
  > **username_2**: This solution can be slow since it re-encodes the video. This solution is much faster: https://video.stackexchange.com/questions/10825/how-to-hold-the-last-frame-when-using-ffmpeg/36571#36571  
  
  ---
  
  ### Answer by username_1 on 2014-05-28. Score: 10
  
  One method is to use the [`overlay` video filter](http://ffmpeg.org/ffmpeg-filters.html#overlay). 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](http://ffmpeg.org/ffmpeg-filters.html#color_002c-haldclutsrc_002c-nullsrc_002c-rgbtestsrc_002c-smptebars_002c-smptehdbars_002c-testsrc) 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](http://ffmpeg.org/ffmpeg.html#Stream-copy) (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.
  
  > **Comments:**
  > **username_0**: 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?  
  > **username_1**: @username_0 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](https://trac.ffmpeg.org/wiki/FFprobeTips).  
  
  ---
  
  ### Answer by username_2 on 2023-06-09. Score: 3
  
  This solution is much faster because it does not require re-encoding.
  
  If there already is an existing audio stream:
  
  ```
  ffmpeg -i in.mp4 -vcodec copy -af apad -t 60 out.mp4
  
  ```
  
  If there is NO existing audio stream:
  
  ```
  ffmpeg -i in.mp4 -f lavfi -i anullsrc -vcodec copy -af apad -t 60 out.mp4
  
  ```
  
  * Note that the `-t 60` refers to the length in seconds of the final output, not the seconds to extend it by.
  * The reason this works is because when the video and audio are different lengths, ffmpeg will extend the shorter stream to match the longer one by default (unless you use the `-shortest` option).
  
  ([credit Gyan](https://stackoverflow.com/questions/66197914/how-to-extend-a-video-by-freezing-the-last-frame-without-reencoding-the-whole-st/66202619#66202619))
  
  > **Comments:**
  > **username_0**: Great solution - Now if I could only also apply a fade-out to the audio this would be perfect.  
  
  ---
  
  ### Answer by username_3 on 2014-05-28. Score: 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.
  
  
  ---
  
  