[FFmpeg-trac] #10348(undetermined:open): Invalid B-frames timestamps importing .h264 or .hevc stream
FFmpeg
trac at avcodec.org
Thu May 11 17:55:12 EEST 2023
#10348: Invalid B-frames timestamps importing .h264 or .hevc stream
-------------------------------------+-------------------------------------
Reporter: slydiman | Owner: (none)
Type: defect | Status: open
Priority: important | Component:
| undetermined
Version: unspecified | Resolution:
Keywords: frames | Blocked By:
timestamp h264 hevc |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Description changed by slydiman:
Old description:
> ffmpeg calculates invalid timestamps importing .h264 or .hevc stream with
> B-frames. Note the video decoder will reorder frames and fix the frames
> timestamps. So it is possible to get the valid file only reencoding the
> video stream. It is impossible to mux the valid file without reencoding.
> Note the invalid file may be played correctly if the video decoder is
> smart enough (MediaPlayerClassic, VLC, etc.). You must playback the
> invalid H264 MP4 in Google Chrome or QuickTime to see the issue. I tested
> invalid HEVC MP4 in Adobe Premiere Pro 2022.
>
> How to reproduce (latest ffmpeg with Lavf60.5.100):
> {{{
> % ffmpeg -i b-frames.h264 -c copy h264_ffmpeg_copy_invalid.mp4
> % ffmpeg -i b-frames.h264 -c h264 h264_ffmpeg_reencode_valid.mp4
> % mp4box -add b-frames.h264 -new h264_mp4box_copy_valid.mp4
>
> % ffmpeg -i b-frames.hevc -c copy hevc_ffmpeg_copy_invalid.mp4
> % ffmpeg -i b-frames.hevc -c hevc hevc_ffmpeg_reencode_valid.mp4
> % mp4box -add b-frames.hevc -new hevc_mp4box_copy_valid.mp4
> }}}
> Samples:
> H264 1920x1080 50fps, High L4.2, yuv420p, recorded by SONY 7SM3
> http://slydiman.me/ffmpeg/b-frames.h264 (12MB)
> http://slydiman.me/ffmpeg/h264_ffmpeg_copy_invalid.mp4 (12MB)
> http://slydiman.me/ffmpeg/h264_ffmpeg_reencode_valid.mp4 (1.4MB)
> http://slydiman.me/ffmpeg/h264_mp4box_copy_valid.mp4 (12MB)
>
> HEVC 4K 23.976fps, Main 10 L5.0, yuv420p10le, recorded by SONY 7M4
> http://slydiman.me/ffmpeg/b-frames.hevc (14MB)
> http://slydiman.me/ffmpeg/hevc_ffmpeg_copy_invalid.mp4 (14MB)
> http://slydiman.me/ffmpeg/hevc_ffmpeg_reencode_valid.mp4 (1.1MB)
> http://slydiman.me/ffmpeg/hevc_mp4box_copy_valid.mp4 (14MB)
New description:
ffmpeg calculates invalid timestamps importing .h264 or .hevc stream with
B-frames. Note the video decoder will reorder frames and fix the frames
timestamps. So it is possible to get the valid file only reencoding the
video stream. It is impossible to mux the valid file without reencoding.
Note the invalid file may be played correctly if the video decoder is
smart enough (MediaPlayerClassic, VLC, etc.). You must playback the
invalid H264 MP4 in Google Chrome or QuickTime to see the issue.
Note ffmpeg muxes an invalid file from HEVC B-frames yuv420p10le. But
everything seems ok in case of HEVC B-frames yuv422p10le with the same
GOP. Google Chrome cannot playback the file
hevc_ffmpeg_copy_yuv422p10le_ok.mp4, so I tested this file in Adobe
Premiere Pro 2022.
How to reproduce (latest ffmpeg with Lavf60.5.100):
{{{
% ffmpeg -i b-frames.h264 -c copy h264_ffmpeg_copy_invalid.mp4
% ffmpeg -i b-frames.h264 -c h264 h264_ffmpeg_reencode_valid.mp4
% mp4box -add b-frames.h264 -new h264_mp4box_copy_valid.mp4
% ffmpeg -i b-frames.hevc -c copy hevc_ffmpeg_copy_invalid.mp4
% ffmpeg -i b-frames.hevc -c hevc hevc_ffmpeg_reencode_valid.mp4
% mp4box -add b-frames.hevc -new hevc_mp4box_copy_valid.mp4
}}}
Samples:
H264 1920x1080 50fps, High L4.2, yuv420p, recorded by SONY 7SM3
http://slydiman.me/ffmpeg/b-frames.h264 (12MB)
http://slydiman.me/ffmpeg/h264_ffmpeg_copy_invalid.mp4 (12MB)
http://slydiman.me/ffmpeg/h264_ffmpeg_reencode_valid.mp4 (1.4MB)
http://slydiman.me/ffmpeg/h264_mp4box_copy_valid.mp4 (12MB)
HEVC 4K 23.976fps, Main 10 L5.0, yuv420p10le, recorded by SONY 7M4
http://slydiman.me/ffmpeg/b-frames.hevc (14MB)
http://slydiman.me/ffmpeg/hevc_ffmpeg_copy_invalid.mp4 (14MB)
http://slydiman.me/ffmpeg/hevc_ffmpeg_reencode_valid.mp4 (1.1MB)
http://slydiman.me/ffmpeg/hevc_mp4box_copy_valid.mp4 (14MB)
HEVC 4K 23.976fps, rext L5.0, yuv422p10le, recorded by SONY 7M4
http://slydiman.me/ffmpeg/b-frames-yuv422p10le.hevc (13MB)
http://slydiman.me/ffmpeg/hevc_ffmpeg_copy_yuv422p10le_ok.mp4 (13MB)
--
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10348#comment:14>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list