I use FFMPEG through Hybrid as the GUI for my encoding tasks. Recently, I encountered a situation where FFMPEG dropped the first two frames of a source video when encoding it. The details and the source video itself are on this post. As you can read from subsequent posts there, the developer of Hybrid, Selur, narrowed the problem down to FFMPEG. He can't do anything about it. So, I am hoping someone more knowledgeable about FFMPEG can figure something out.
I've only seen this occur twice in all the years I've been encoding. Both in my current encoding project. The only commonalities I can tell are both were cut from a longer video, both had over a dozen frames with no changes from the cut point, cutting at an earlier point results in the proper number of frames encoded in both cases.
Small footnote. The source is 49 frames long and the encode is 47 frames. I forgot Aegisub starts from frame 0 when I posted.
+ Reply to Thread
Results 1 to 7 of 7
-
-
It's normal and expected
You've cut the sample on an open GOP, so 2 preceding b-frames are discarded by many decoders. Other decoders put "placeholders" there, as duplicate frames.
The solution is don't cut on open GOP's (cut only on IDR or "true" keyframes) . Sometimes this can be difficult for some BD's - some BD's have open GOPs for several minutes. Adjust your workflow accordingly or at least be aware of this common issue -
Thanks for that. I have a few questions.
First, what sort of tools can identify an open GOP in a video stream?
Second, would an open GOP ever be the frame 0 of a BD video stream?
Third, is FFMPEG one of those decoders that will always discard those preceding b-frames and that will not be changing? -
I believe the sample was trimmed from an open GOP source without reencoding. The first I frame has a display time of 0.083 ms so there are two missing frames at the start of the video (display time=0 and 41 ms) that can't be reconstructed (they were part of the previous GOP but their data appeared after the I frame of the next GOP -- in coded order). This throws off the calculations in many programs.
command line:
Code:ffprobe -print_format json -show_frames short.mkv
Code:{ "frames": [ { "media_type": "video", "stream_index": 0, "key_frame": 1, "pts": 83, "pts_time": "0.083000", "pkt_dts": 41, "pkt_dts_time": "0.041000", "best_effort_timestamp": 83, "best_effort_timestamp_time": "0.083000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "5772", "pkt_size": "390540", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "I", "coded_picture_number": 4, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:14" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:14" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 125, "pts_time": "0.125000", "pkt_dts": 125, "pkt_dts_time": "0.125000", "best_effort_timestamp": 125, "best_effort_timestamp_time": "0.125000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "992425", "pkt_size": "197358", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 8, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:15" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:15" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 166, "pts_time": "0.166000", "pkt_dts": 166, "pkt_dts_time": "0.166000", "best_effort_timestamp": 166, "best_effort_timestamp_time": "0.166000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "1189791", "pkt_size": "164595", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 9, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:16" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:16" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 208, "pts_time": "0.208000", "pkt_dts": 208, "pkt_dts_time": "0.208000", "best_effort_timestamp": 208, "best_effort_timestamp_time": "0.208000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "748954", "pkt_size": "243463", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "P", "coded_picture_number": 7, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:17" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:17" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 250, "pts_time": "0.250000", "pkt_dts": 250, "pkt_dts_time": "0.250000", "best_effort_timestamp": 250, "best_effort_timestamp_time": "0.250000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "1585747", "pkt_size": "195077", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 11, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:18" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:18" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 291, "pts_time": "0.291000", "pkt_dts": 291, "pkt_dts_time": "0.291000", "best_effort_timestamp": 291, "best_effort_timestamp_time": "0.291000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "1780832", "pkt_size": "162958", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 12, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:19" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:19" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 333, "pts_time": "0.333000", "pkt_dts": 333, "pkt_dts_time": "0.333000", "best_effort_timestamp": 333, "best_effort_timestamp_time": "0.333000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "1354394", "pkt_size": "231335", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "P", "coded_picture_number": 10, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:15:20" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:15:20" } ] } ] }, (many frames because of post size limit) { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 1751, "pts_time": "1.751000", "pkt_dts": 1751, "pkt_dts_time": "1.751000", "best_effort_timestamp": 1751, "best_effort_timestamp_time": "1.751000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "8899443", "pkt_size": "137780", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 47, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:06" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:06" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 1793, "pts_time": "1.793000", "pkt_dts": 1793, "pkt_dts_time": "1.793000", "best_effort_timestamp": 1793, "best_effort_timestamp_time": "1.793000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "8557047", "pkt_size": "187725", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "P", "coded_picture_number": 45, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:07" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:07" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 1835, "pts_time": "1.835000", "pkt_dts": 1835, "pkt_dts_time": "1.835000", "best_effort_timestamp": 1835, "best_effort_timestamp_time": "1.835000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "9317958", "pkt_size": "223767", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 49, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:08" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:08" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 1876, "pts_time": "1.876000", "best_effort_timestamp": 1876, "best_effort_timestamp_time": "1.876000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "9541733", "pkt_size": "172112", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 50, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:09" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:09" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 1918, "pts_time": "1.918000", "best_effort_timestamp": 1918, "best_effort_timestamp_time": "1.918000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "9037231", "pkt_size": "280719", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "P", "coded_picture_number": 48, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:10" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:10" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 1960, "pts_time": "1.960000", "best_effort_timestamp": 1960, "best_effort_timestamp_time": "1.960000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "9914428", "pkt_size": "152901", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "B", "coded_picture_number": 52, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:11" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:11" } ] } ] }, { "media_type": "video", "stream_index": 0, "key_frame": 0, "pts": 2002, "pts_time": "2.002000", "best_effort_timestamp": 2002, "best_effort_timestamp_time": "2.002000", "pkt_duration": 41, "pkt_duration_time": "0.041000", "pkt_pos": "9713853", "pkt_size": "200567", "width": 1920, "height": 1080, "pix_fmt": "yuv420p", "sample_aspect_ratio": "1:1", "pict_type": "P", "coded_picture_number": 51, "display_picture_number": 0, "interlaced_frame": 0, "top_field_first": 0, "repeat_pict": 0, "color_range": "tv", "color_space": "bt709", "color_primaries": "bt709", "color_transfer": "bt709", "chroma_location": "left", "tags": { "timecode": "01:19:17:12" }, "side_data_list": [ { "side_data_type": "SMPTE 12-1 timecode", "timecodes": [ { "value": "01:19:17:12" } ] } ] } ] } ffprobe version 5.1.2-full_build-www.gyan.dev Copyright (c) 2007-2022 the FFmpeg developers built with gcc 12.1.0 (Rev2, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 Input #0, matroska,webm, from 'C:\Users\John\Desktop\short.mkv': Metadata: encoder : libebml v1.4.4 + libmatroska v1.7.1 creation_time : 2022-12-12T05:34:49.000000Z Duration: 00:00:02.04, start: 0.083000, bitrate: 39404 kb/s Chapters: Chapter #0:0: start 0.000000, end 1.919000 Metadata: title : mark Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn (default) Metadata: BPS : 39378070 DURATION : 00:00:02.044000000 NUMBER_OF_FRAMES: 49 NUMBER_OF_BYTES : 10061097 _STATISTICS_WRITING_APP: mkvmerge v72.0.0 ('Minuano (Six-eight)') 64-bit _STATISTICS_WRITING_DATE_UTC: 2022-12-12 05:34:49 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
-
some commonly used free tools such as h264_parse, ffprobe are sometimes incorrect/unreliable/misleading. You can demonstrate that on your sample - look at jagabo's ffprobe report and it shows "coded_picture_number": 52 , but there are only 49 coded frames.
=> A commercial parser like elecard streameye is most reliable. DGIndexNV is also reliable for identifying IDR frames (it's free now, but requires compatible NVidia card)
Second, would an open GOP ever be the frame 0 of a BD video stream?
Third, is FFMPEG one of those decoders that will always discard those preceding b-frames and that will not be changing?
yes, that is ffmpeg behavior and it will not change. Those 2 frames are technically "garbage frames" and incomplete
And my previous phrasing is not correct; the decoder can actually the same for say ffms2/lsmash in avsiynth/vapoursynth vs. ffmpeg - ie. libavcodec decoder - it's the framework that decides what to do with those 2 decoded garbage frames . Frameservers like avisynth/vapoursynth tend to keep the garbage frames as duplicates for timing purposes (could be important if you're subbing) . ffmpeg drops the garbage frames -
Good to know that won't ever be a problem.
Frameservers like avisynth/vapoursynth tend to keep the garbage frames as duplicates for timing purposes (could be important if you're subbing) . -
Similar Threads
-
Logitech C920s webcam irregularly dropping frames
By palettenheinze in forum Newbie / General discussionsReplies: 4Last Post: 18th Jun 2020, 14:20 -
Reading Video Frames Using ffmpeg
By chris319 in forum ProgrammingReplies: 15Last Post: 4th Nov 2019, 15:10 -
Dropping frames using madvr in MPC-HC in 4k@24 HDR
By bossystyle in forum Software PlayingReplies: 0Last Post: 24th May 2019, 16:45 -
AmarecTV freezing, dropping frames, and not functioning at all
By ArianK in forum Capturing and VCRReplies: 2Last Post: 23rd May 2018, 16:32 -
Can I force ffmpeg to transcode 59.94 frames to display at 25 frames per se
By oduodui in forum EditingReplies: 4Last Post: 28th Apr 2018, 09:24