0

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
New contributor
Little_Ye233 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
5
  • 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.
    – slhck
    Nov 25 at 13:54
  • @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. Nov 27 at 1:40
  • 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
    2 days ago
  • @slhck The black frames are still here but all the players behave the same. yesterday
  • 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
    yesterday

Your Answer

Little_Ye233 is a new contributor. Be nice, and check out our Code of Conduct.

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

Browse other questions tagged or ask your own question.