Answers.Body: <p>Try to place the <code>-ss</code> and <code>-to</code> after the input: </p>
  
  <pre><code>ffmpeg \
    -i input-original.mp4 \
    -ss 00:11:42 \
    -to 01:11:22 \
    -c copy \
    output-trimmed.mp4
  </code></pre>
  
  <p>According to @Gyan (<a href="https://stackoverflow.com/questions/45004159/ffmpeg-ss-and-t-for-cutting-mp3">https://stackoverflow.com/questions/45004159/ffmpeg-ss-and-t-for-cutting-mp3</a>)</p>
  
  <blockquote>
    <p>When -ss and -t are placed before the input, ffmpeg resorts to fast
    seek which relies on the index of the input to allow ffmpeg to start
    and stop seeking. MP3s don't have indices, so ffmpeg estimates
    duration via bitrate. This can be inaccurate.</p>
    
    <p>When -ss and -t are placed after the input, ffmpeg counts demuxed
    packets. This will be accurate.</p>
  </blockquote>
  
  <p>If it doesn't work you can also try to convert your video to intra-frame format (try <code>ffvhuff</code>), trim it and then convert it back to mp4 but this will slightly decrease the quality of the trimmed output. Keep in mind that <code>ffvhuff</code> will create huge file in size so make sure you have enough free space if you want to go this way. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-12T11:33:34.243Z
Answers.LastActivityDate: 2019-11-12T11:33:34.243Z
Answers.UserDisplayName: Georgi Stoyanov
Answers.Body: <p>You can achieve the desired video without any broken or black frames by decoding and re-encoding the video. Although you need to know video codec and bit-rate in order to achieve so</p>
  
  <pre><code>ffmpeg -i input-original.mp4 -ss 00:11:42 -strict -2 -to 01:11:22 -codec:v h264 -b:v 100k;
  </code></pre>
  
  <p><em>Note:</em> If this does not work, try to change <code>-to</code> switch to <code>-t</code> and specify the duration.<br>
  Hope this helps.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-13T09:15:51.237Z
Answers.LastActivityDate: 2019-11-14T05:29:37.673Z
Answers.LastEditDate: 2019-11-14T05:29:37.673Z
Answers.UserDisplayName: Ashish Pandey
Body: <p>I'm using ffmpeg to trim a Zoom video recording (format: ISO Media, MP4 v2 [ISO 14496-14]) via this command:</p>
  <pre><code>ffmpeg \
    -ss 00:11:42 \
    -to 01:11:22 \
    -i input-original.mp4 \
    -c copy \
    output-trimmed.mp4
  </code></pre>
  <p>The input file looks great, but the output has a few dropped frames at the beginning, so for the first few seconds it looks like this:</p>
  <p><a href="https://i.sstatic.net/fot19.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fot19.png" alt="enter image description here" /></a></p>
  <p>A few seconds later, it goes back to normal and it doesn't have any other issues. I'm wondering if there is a way to fix this problem.</p>
  <p>EDIT: Actually, this seems to be a VLC-specific problem. Once I upload it to Vimeo, the weird frames go away. Still, I'd like to know if there is a way to prevent this.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-14T04:40:30.793Z
Comments.Text: It's probably not a FFmpeg issue — the resulting video should be good (if the source was good, naturally). Try `ffplay output-trimmed.mp4` for playing it back.
Comments.UserDisplayName: MarianD
Tags: <ffmpeg><mp4><vlc>
Title: How to prevent ffmpeg from dropping frames when trimming?
UserDisplayName: nachocab
ThreadText: # How to prevent ffmpeg from dropping frames when trimming?
  
  (Asked by: username_0 on 2019-11-10)
  
  I'm using ffmpeg to trim a Zoom video recording (format: ISO Media, MP4 v2 [ISO 14496-14]) via this command:
  
  ```
  ffmpeg \
    -ss 00:11:42 \
    -to 01:11:22 \
    -i input-original.mp4 \
    -c copy \
    output-trimmed.mp4
  
  ```
  
  The input file looks great, but the output has a few dropped frames at the beginning, so for the first few seconds it looks like this:
  
  [![enter image description here](https://i.sstatic.net/fot19.png)](https://i.sstatic.net/fot19.png)
  
  A few seconds later, it goes back to normal and it doesn't have any other issues. I'm wondering if there is a way to fix this problem.
  
  EDIT: Actually, this seems to be a VLC-specific problem. Once I upload it to Vimeo, the weird frames go away. Still, I'd like to know if there is a way to prevent this.
  
  **Tags:** ffmpeg, mp4, vlc
  
  > **Comments:**
  > **username_1**: It's probably not a FFmpeg issue — the resulting video should be good (if the source was good, naturally). Try `ffplay output-trimmed.mp4` for playing it back.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-11-12. Score: 3
  
  Try to place the `-ss` and `-to` after the input:
  
  ```
  ffmpeg \
    -i input-original.mp4 \
    -ss 00:11:42 \
    -to 01:11:22 \
    -c copy \
    output-trimmed.mp4
  
  ```
  
  According to @Gyan (<https://stackoverflow.com/questions/45004159/ffmpeg-ss-and-t-for-cutting-mp3>)
  
  > When -ss and -t are placed before the input, ffmpeg resorts to fast
  > seek which relies on the index of the input to allow ffmpeg to start
  > and stop seeking. MP3s don't have indices, so ffmpeg estimates
  > duration via bitrate. This can be inaccurate.
  >
  > When -ss and -t are placed after the input, ffmpeg counts demuxed
  > packets. This will be accurate.
  
  If it doesn't work you can also try to convert your video to intra-frame format (try `ffvhuff`), trim it and then convert it back to mp4 but this will slightly decrease the quality of the trimmed output. Keep in mind that `ffvhuff` will create huge file in size so make sure you have enough free space if you want to go this way.
  
  
  ---
  
  ### Answer by username_3 on 2019-11-13. Score: 1
  
  You can achieve the desired video without any broken or black frames by decoding and re-encoding the video. Although you need to know video codec and bit-rate in order to achieve so
  
  ```
  ffmpeg -i input-original.mp4 -ss 00:11:42 -strict -2 -to 01:11:22 -codec:v h264 -b:v 100k;
  
  ```
  
  *Note:* If this does not work, try to change `-to` switch to `-t` and specify the duration.  
  Hope this helps.
  
  
  ---
  
  