Answers.Body: <p>If your video has fixed frame rate, you probably mean by “frozen part” the part with the <em>same frame repeated many times.</em></p>
  
  <p>To remove duplicate frames you may apply the <a href="https://ffmpeg.org/ffmpeg-filters.html#mpdecimate" rel="nofollow noreferrer">mpdecimate</a> filter.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-06T09:43:42.743Z
Answers.Text: Thanks to your input I have found [this question on Stackoverflow](https://stackoverflow.com/questions/37088517/ffmpeg-remove-sequentially-duplicate-frames/37089629) which explains how to use it. Unfortunately using the command `ffmpeg -i in.mkv -vf mpdecimate out.mkv` reduces the file size considerably but **does not cut away** the duplicated frames: the video length remains the same.
Answers.UserDisplayName: Marco Lackovic
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-05T14:00:46.610Z
Answers.LastActivityDate: 2019-10-05T14:00:46.610Z
Answers.UserDisplayName: MarianD
Answers.Body: <p>What you need in addition to remove the frozen parts is <strong>setpts</strong>. Keep in mind that <strong>mpdecimate</strong> works only on the video stream, so you have to remove the audio because is not going to be synced.</p>
  <pre><code>ffmpeg -i video.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB -an video-fixed.mp4
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-19T13:15:16.380Z
Answers.LastActivityDate: 2022-01-19T15:41:49.107Z
Answers.LastEditDate: 2022-01-19T15:41:49.107Z
Answers.UserDisplayName: Ivaylo Hristov
Body: <p>When dealing with corrupted videos, <code>ffmpeg</code> is a great to tool to automatically <a href="https://video.stackexchange.com/questions/18220/fix-bad-files-and-streams-with-ffmpeg-so-vlc-and-other-players-would-not-crash/">fix errors</a>.</p>
  
  <p>Is there a way, with <code>ffmpeg</code> or another similar tool, to automatically remove/drop/trim/cut away frozen parts from a file, both video and audio streams?</p>
  
  <p>Using a combination of <code>mpdecimate</code> and <code>map</code> it's possible to obtain the video stream only with:</p>
  
  <pre><code>ffmpeg -i input.ext -vf mpdecimate -map 0:v output.mp4
  </code></pre>
  
  <p>How to do the same thing with all streams of the file, audio and video?</p>
  
  <p>Given a video with two streams like:</p>
  
  <pre><code>     0       1         2       3         4
  video|AAAAAAA|FFFFFFFFF|BBBBBBB|FFFFFFFFF|
  audio|XXXXXXX|YYYYYYYYY|ZZZZZZZ|KKKKKKKKK|
  </code></pre>
  
  <p>where <code>A</code> and <code>B</code> are the good parts to mantain and <code>F</code> are the frozen parts to be trimmed away, I want obtain a "cleaned" video (with the frozen parts and its associated audio removed) which in the end would look like:</p>
  
  <pre><code>0       1       2
  video|AAAAAAA|BBBBBBB|
  audio|XXXXXXX|ZZZZZZZ|
  </code></pre>
  
Tags: <ffmpeg>
Title: Remove frozen parts from a corrupted video
UserDisplayName: Marco Lackovic
ThreadText: # Remove frozen parts from a corrupted video
  
  (Asked by: username_0 on 2019-10-05)
  
  When dealing with corrupted videos, `ffmpeg` is a great to tool to automatically [fix errors](https://video.stackexchange.com/questions/18220/fix-bad-files-and-streams-with-ffmpeg-so-vlc-and-other-players-would-not-crash/).
  
  Is there a way, with `ffmpeg` or another similar tool, to automatically remove/drop/trim/cut away frozen parts from a file, both video and audio streams?
  
  Using a combination of `mpdecimate` and `map` it's possible to obtain the video stream only with:
  
  ```
  ffmpeg -i input.ext -vf mpdecimate -map 0:v output.mp4
  
  ```
  
  How to do the same thing with all streams of the file, audio and video?
  
  Given a video with two streams like:
  
  ```
       0       1         2       3         4
  video|AAAAAAA|FFFFFFFFF|BBBBBBB|FFFFFFFFF|
  audio|XXXXXXX|YYYYYYYYY|ZZZZZZZ|KKKKKKKKK|
  
  ```
  
  where `A` and `B` are the good parts to mantain and `F` are the frozen parts to be trimmed away, I want obtain a "cleaned" video (with the frozen parts and its associated audio removed) which in the end would look like:
  
  ```
  0       1       2
  video|AAAAAAA|BBBBBBB|
  audio|XXXXXXX|ZZZZZZZ|
  
  ```
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-10-05. Score: 1
  
  If your video has fixed frame rate, you probably mean by “frozen part” the part with the *same frame repeated many times.*
  
  To remove duplicate frames you may apply the [mpdecimate](https://ffmpeg.org/ffmpeg-filters.html#mpdecimate) filter.
  
  > **Comments:**
  > **username_0**: Thanks to your input I have found [this question on Stackoverflow](https://stackoverflow.com/questions/37088517/ffmpeg-remove-sequentially-duplicate-frames/37089629) which explains how to use it. Unfortunately using the command `ffmpeg -i in.mkv -vf mpdecimate out.mkv` reduces the file size considerably but **does not cut away** the duplicated frames: the video length remains the same.  
  
  ---
  
  ### Answer by username_2 on 2022-01-19. Score: 0
  
  What you need in addition to remove the frozen parts is **setpts**. Keep in mind that **mpdecimate** works only on the video stream, so you have to remove the audio because is not going to be synced.
  
  ```
  ffmpeg -i video.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB -an video-fixed.mp4
  
  ```
  
  
  ---
  
  