<p>To get the correct behavior on all players, you have to re-encode the video, i.e. remove the <code>-c:v copy</code>/<code>-vcodec copy</code> part and replace it with, for example:</p>
<pre><code>-c:v libx264 -crf 23
</code></pre>
<p>Pair it with a positive specification for <code>-ss</code>, e.g. <code>-ss 0.2</code>, to get rid of whatever black frames there were in the beginning.</p>
<p>This will ensure that all frames get re-encoded.</p>

CC BY-SA 4.0
2021-12-01T12:21:44.077Z
2021-12-01T12:21:44.077Z
slhck
<p>I have a 30-fps video just downloaded by <code>youtube-dl</code>, and it seems to have black frames in the beginning of it.</p>
<p>Part of the result of <code>ffprobe youtube-dl.mp4</code>:</p>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtube-dl.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
  Duration: 00:04:53.69, start: 0.000000, bitrate: 1250 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1115 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
</code></pre>
<p>Then I tried to trim the video using <code>ffmpeg -i youtube-dl.mp4 -ss 0:0:0 -to 0:4:37 -vcodec copy -acodec copy youtube-dl-trimmed.mp4</code>. Part of the result is below:</p>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtube-dl.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1115 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
Output #0, mp4, to 'youtube-dl-trimmed.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1115 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
Stream mapping:
  Stream #0:0 -&gt; #0:0 (copy)
  Stream #0:1 -&gt; #0:1 (copy)
Press [q] to stop, [?] for help
frame= 8288 fps=0.0 q=-1.0 Lsize=   43944kB time=00:04:36.99 bitrate=1299.6kbits/s speed= 382x
video:39364kB audio:4329kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.575328%
</code></pre>
<p>And use <code>ffprobe</code> to probe it:</p>
<pre><code>Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtube-dl-trimmed.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
  Duration: 00:04:37.02, start: 0.000000, bitrate: 1299 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1167 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
</code></pre>
<p>What I wonder is that the playback results of some applications and video processing libraries vary. In some of them the video still remains the black frames, but in the others the first 22 frames disappear and certainly the total number of frames is decreased. The test result about the black frames is below:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">Applications or Libraries</th>
<th style="text-align: center;">youtube-dl.mp4</th>
<th style="text-align: center;">youtube-dl-trimmed.mp4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">ffplay</td>
<td style="text-align: center;">remained</td>
<td style="text-align: center;">disappeared</td>
</tr>
<tr>
<td style="text-align: center;">PotPlayer</td>
<td style="text-align: center;">remained</td>
<td style="text-align: center;">remained</td>
</tr>
<tr>
<td style="text-align: center;">VLC Player</td>
<td style="text-align: center;">remained</td>
<td style="text-align: center;">remained</td>
</tr>
<tr>
<td style="text-align: center;">Aegisub</td>
<td style="text-align: center;">remained</td>
<td style="text-align: center;">disappeared</td>
</tr>
<tr>
<td style="text-align: center;">Adobe Premiere</td>
<td style="text-align: center;">remained</td>
<td style="text-align: center;">remained</td>
</tr>
<tr>
<td style="text-align: center;">OpenCV library</td>
<td style="text-align: center;">remained</td>
<td style="text-align: center;">disappeared</td>
</tr>
</tbody>
</table>
</div>
<p>It bothers me a lot because I use Aegisub to create ASS subtitles but I use FFmpeg to burn a subtitle into <code>youtube-dl-trimmed.mp4</code>, the black frames remain and thus the showing time of every line isn't fit with the speakers' words. Also the black frames still here when using <code>ffplay</code> to play the hard-subtitled video. What's wrong with these videos? Does <code>youtube-dl-trimmed.mp4</code> have dropped frames? Any reply is appreciated.</p>
<hr />
<p><strong>EDIT:</strong></p>
<p>Version string and configuration options of my <code>ffmpeg</code>:</p>
<pre><code>ffmpeg version git-2020-05-15-b18fd2b Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200513
configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
--enable-libdav1d --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine
--enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora
--enable-libtwolame --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2
--enable-libzimg --enable-lzma --enable-zlib --enable-gmp
--enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc
--enable-libmysofa --enable-libspeex --enable-libxvid
--enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec
--enable-cuda-llvm --enable-cuvid --enable-d3d11va
--enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
--enable-libopenmpt --enable-amf
libavutil      56. 45.100 / 56. 45.100
libavcodec     58. 84.100 / 58. 84.100
libavformat    58. 43.100 / 58. 43.100
libavdevice    58.  9.103 / 58.  9.103
libavfilter     7. 81.100 /  7. 81.100
libswscale      5.  6.101 /  5.  6.101
libswresample   3.  6.100 /  3.  6.100
libpostproc    55.  6.100 / 55.  6.100
</code></pre>
<hr />
<p><strong>EDIT 2:</strong></p>
<p>@slhck provided a workaround in the comments. Re-encoding the video can  keep all players behaving well.</p>

CC BY-SA 4.0
2021-11-25T13:54:07.367Z
Why do you expect `-ss 0:0:0 -to 0:4:37` to trim off frames in the beginning? You start at 0; there is nothing before 0. If you wanted to trim off some frames, `ss` should be a positive number. Please always show the complete uncut command line output.
slhck
CC BY-SA 4.0
2021-11-27T01:40:51.863Z
@slhck I used `-ss 0:0:0` because I didn't want to calculate how long the black frames lasted and they just lasted less than a second in fact, then I decided to keep the frames. And the command line output is full actually. As for the uncut output, I have just added the configuration options and version string to the post. These things and the **part of the result** makes up the full output.
Little_Ye233
CC BY-SA 4.0
2021-11-28T19:39:35.483Z
So basically when you remux the file without actually trimming anything (`-ss 0`), the players show different behavior? What if you re-encode with `-c:v libx264 -crf 18` instead of `-vcodec copy`, what happens?
slhck
CC BY-SA 4.0
2021-11-30T03:24:37.830Z
@slhck The black frames are still here but all the players behave the same.
Little_Ye233
CC BY-SA 4.0
2021-11-30T08:53:44.287Z
Then I would recommend doing the re-encoding, but specifying a different, positive offset for `-ss` so that the black frames disappear. I am quite sure there's no easy way around this, in particular if you want all players behaving the same.
slhck
CC BY-SA 4.0
2021-12-01T11:00:25.757Z
@slhck You are right. I just found other videos had similar problems like this one and some of them even had a long period black frames. After re-encoding them the problem was solved. Thank you a lot.
Little_Ye233
<ffmpeg><subtitles>
Possible dropped frames after trimming a video
Little_Ye233
# Possible dropped frames after trimming a video

(Asked by: username_0 on 2021-11-25)

I have a 30-fps video just downloaded by youtube-dl, and it seems to have black frames in the beginning of it.
Part of the result of ffprobe youtube-dl.mp4:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtube-dl.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
  Duration: 00:04:53.69, start: 0.000000, bitrate: 1250 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1115 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.

Then I tried to trim the video using ffmpeg -i youtube-dl.mp4 -ss 0:0:0 -to 0:4:37 -vcodec copy -acodec copy youtube-dl-trimmed.mp4. Part of the result is below:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtube-dl.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1115 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
Output #0, mp4, to 'youtube-dl-trimmed.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1115 kb/s, 30 fps, 30 tbr, 15360 tbn, 15360 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 8288 fps=0.0 q=-1.0 Lsize=   43944kB time=00:04:36.99 bitrate=1299.6kbits/s speed= 382x
video:39364kB audio:4329kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.575328%

And use ffprobe to probe it:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'youtube-dl-trimmed.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.43.100
  Duration: 00:04:37.02, start: 0.000000, bitrate: 1299 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 1167 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : ISO Media file produced by Google Inc.

What I wonder is that the playback results of some applications and video processing libraries vary. In some of them the video still remains the black frames, but in the others the first 22 frames disappear and certainly the total number of frames is decreased. The test result about the black frames is below:




Applications or Libraries
youtube-dl.mp4
youtube-dl-trimmed.mp4




ffplay
remained
disappeared


PotPlayer
remained
remained


VLC Player
remained
remained


Aegisub
remained
disappeared


Adobe Premiere
remained
remained


OpenCV library
remained
disappeared




It bothers me a lot because I use Aegisub to create ASS subtitles but I use FFmpeg to burn a subtitle into youtube-dl-trimmed.mp4, the black frames remain and thus the showing time of every line isn't fit with the speakers' words. Also the black frames still here when using ffplay to play the hard-subtitled video. What's wrong with these videos? Does youtube-dl-trimmed.mp4 have dropped frames? Any reply is appreciated.

EDIT:
Version string and configuration options of my ffmpeg:
ffmpeg version git-2020-05-15-b18fd2b Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200513
configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
--enable-libdav1d --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine
--enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora
--enable-libtwolame --enable-libvpx --enable-libwavpack
--enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2
--enable-libzimg --enable-lzma --enable-zlib --enable-gmp
--enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc
--enable-libmysofa --enable-libspeex --enable-libxvid
--enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec
--enable-cuda-llvm --enable-cuvid --enable-d3d11va
--enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
--enable-libopenmpt --enable-amf
libavutil      56. 45.100 / 56. 45.100
libavcodec     58. 84.100 / 58. 84.100
libavformat    58. 43.100 / 58. 43.100
libavdevice    58.  9.103 / 58.  9.103
libavfilter     7. 81.100 /  7. 81.100
libswscale      5.  6.101 /  5.  6.101
libswresample   3.  6.100 /  3.  6.100
libpostproc    55.  6.100 / 55.  6.100


EDIT 2:
@username_1 provided a workaround in the comments. Re-encoding the video can  keep all players behaving well.

**Tags:** ffmpeg, subtitles

> **Comments:**
> **username_1**: Why do you expect `-ss 0:0:0 -to 0:4:37` to trim off frames in the beginning? You start at 0; there is nothing before 0. If you wanted to trim off some frames, `ss` should be a positive number. Please always show the complete uncut command line output.  
> **username_0**: @username_1 I used `-ss 0:0:0` because I didn't want to calculate how long the black frames lasted and they just lasted less than a second in fact, then I decided to keep the frames. And the command line output is full actually. As for the uncut output, I have just added the configuration options and version string to the post. These things and the **part of the result** makes up the full output.  
> **username_1**: So basically when you remux the file without actually trimming anything (`-ss 0`), the players show different behavior? What if you re-encode with `-c:v libx264 -crf 18` instead of `-vcodec copy`, what happens?  
> **username_0**: @username_1 The black frames are still here but all the players behave the same.  
> **username_1**: Then I would recommend doing the re-encoding, but specifying a different, positive offset for `-ss` so that the black frames disappear. I am quite sure there's no easy way around this, in particular if you want all players behaving the same.  
> **username_0**: @username_1 You are right. I just found other videos had similar problems like this one and some of them even had a long period black frames. After re-encoding them the problem was solved. Thank you a lot.  

---

## 1 answers

### Answer by username_1 on 2021-12-01. Score: 1

To get the correct behavior on all players, you have to re-encode the video, i.e. remove the -c:v copy/-vcodec copy part and replace it with, for example:
-c:v libx264 -crf 23

Pair it with a positive specification for -ss, e.g. -ss 0.2, to get rid of whatever black frames there were in the beginning.
This will ensure that all frames get re-encoded.


---

