#11683 closed defect (wontfix)
"libx265" generated videos abnormal frames parsing?
| Reported by: | rgr | Owned by: | |
|---|---|---|---|
| Priority: | important | Component: | avformat |
| Version: | 7.1 | Keywords: | mp4 libx265 OGOP |
| Cc: | rgr, MasterQuestionable | Blocked By: | |
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | yes |
Description
Summary of the bug:
The encoded MP4/H265 file doesn't play correctly and is 2 frames shorter. When I change the codec to H264, everything works fine.
ffmpeg reports 465 frames encoded:
encoded 465 frames in 46.29s (10.05 fps), 8883.04 kb/s, Avg QP:25.39
[aac @ 000001c87a123040] Qavg: 881.112
In VirtualDub with the latest ffmpeg libraries, the last frames are displayed in random order. Seek-by-frame often causes jumps to the wrong frame (each frame has a label with its number). Magix Vegas only reads 463 frames.
After changing the codec in the ffmpeg command to libx264, all problems disappear.
https://gcdnb.pbrd.co/images/ZSD7tRo9KuG7.png?o=1
How to reproduce:
% ffmpeg -avisynth_flags +all -i "2025_04_10 20_44_52 (PXL_20250410_204452830).avs" -c:v libx265 -preset slow -crf 19 -pix_fmt yuv420p -c:a aac -b:a 192k "2025_04_10 20_44_52 (PXL_20250410_204452830)(H265).mp4" ffmpeg version 2025-07-23-git-829680f96a-full_build-www.gyan.dev built on 2025-07-23
Files: https://files.fm/u/jq3yzf4za7 (output H265 included)
Change History (10)
comment:1 by , 10 months ago
comment:2 by , 9 months ago
You don't even need to download my files, just any ffmpeg/libx265 encoded one is enough.
comment:3 by , 9 months ago
| Analyzed by developer: | set |
|---|---|
| Cc: | added |
| Keywords: | libx265 OGOP added; h265 encoding removed |
| Summary: | Error encoding to H265 (H264 is ok) → "libx265" generated videos abnormal frames parsing? |
͏ I guess the cause might be OGOP (Open GOP).
͏ [ ^ https://trac.ffmpeg.org/ticket/5309#comment:16 ]
͏ What are the interpreted encoding configs (returned by "libx265")?
͏ (or "Encoding settings" of MediaInfo)
͏ Should:
͏ ffmpeg -y -v debug -hide_banner -nostdin -nostats -f lavfi -i "testsrc2=1920x1080:30:d=15" -c:v libx265 -preset slow -crf 19 "Out.mkv"
͏ ; reproduce then?
͏ To explicitly disable OGOP, add: -x265-params "open-gop=0"
͏ More tools for output analysis:
͏ ffprobe -v warning -hide_banner -threads 0 -show_entries "frame" -select_streams v:0 -of "xml" "Out.mkv" -o "Out.mkv.xml"
͏ https://media-analyzer.pro/app
͏ https://hintfo.com/
comment:4 by , 9 months ago
General Complete name : X:\_moje\_asia\$ robimy od nowa\2024_12_25 12_56_07 (PXL_20241225_125607464) (AV1) (H265).mp4 Format : MPEG-4 Format profile : Base Media Codec ID : isom (isom/iso2/mp41) File size : 7.00 MiB Duration : 10 s 911 ms Overall bit rate : 5 385 kb/s Frame rate : 59.484 FPS Writing application : Lavf62.1.103 Video ID : 1 Format : HEVC Format/Info : High Efficiency Video Coding Format profile : Main@L4.1@Main Codec ID : hev1 Codec ID/Info : High Efficiency Video Coding Duration : 10 s 911 ms Bit rate : 5 177 kb/s Width : 1 080 pixels Height : 1 920 pixels Display aspect ratio : 0.562 Frame rate mode : Constant Frame rate : 59.484 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.042 Stream size : 6.73 MiB (96%) Writing library : x265 4.1+189-c8ceb6b8a:[Windows][GCC 15.1.0][64 bit] 8bit+10bit+12bit Encoding settings : cpuid=1111039 / frame-threads=4 / numa-pools=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=1080x1920 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-eob / no-eos / no-hrd / info / hash=0 / temporal-layers=0 / open-gop / min-keyint=25 / keyint=250 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=4 / scenecut=40 / no-hist-scenecut / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=4 / selective-sao=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=19.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=1 / colorprim=1 / transfer=1 / colormatrix=1 / chromaloc=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=255 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / scenecut-aware-qp=0conformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0 / no-vbv-live-multi-pass / no-mcstf / no-sbrc / no-frame-rc Color range : Full Color primaries : BT.709 Transfer characteristics : BT.709 Matrix coefficients : BT.709 Codec configuration box : hvcC Audio ID : 2 Format : AAC LC Format/Info : Advanced Audio Codec Low Complexity Codec ID : mp4a-40-2 Duration : 10 s 908 ms Source duration : 10 s 923 ms Bit rate mode : Constant Bit rate : 192 kb/s Channel(s) : 2 channels Channel layout : L R Sampling rate : 48.0 kHz Frame rate : 46.875 FPS (1024 SPF) Compression mode : Lossy Stream size : 255 KiB (4%) Source stream size : 255 KiB (4%) Title : SoundHandle Language : English Default : Yes Alternate group : 1
comment:5 by , 9 months ago
ffmpeg -y -v debug -hide_banner -nostdin -nostats -f lavfi -i "testsrc2=1920x1080:30:d=15" -c:v libx265 -preset slow -crf 19 "Out.mkv"
If I save to "out.mkv," there's no problem. If I save to "out.mp4," the problem persists.
comment:6 by , 9 months ago
| Component: | avcodec → avformat |
|---|---|
| Keywords: | mp4 added |
͏ Would below reproduce?
͏ ffmpeg -y -v debug -hide_banner -nostdin -nostats -f lavfi -i "testsrc2=320x240:25:d=20" -c:v libx265 -preset slow -crf 19 -x265-params "open-gop=0" "Out.mp4"
͏ ffmpeg -y -v debug -hide_banner -nostdin -nostats -f lavfi -i "testsrc2=320x240:25:d=20" -c:v libx265 -preset slow -crf 19 -use_editlist 0 "Out.mp4"
͏ .
͏ Does it affect ".mov" too?
͏ Need not to post here unspecific logs.
͏ Selected observations shall help more.
͏ And if viable: add attachments to the Trac directly.
͏ The 2 uploaded XML:
͏ ("Out.mkv.xml", "Out.mp4.xml")
͏ Exhibited no practical difference between.
͏ Which means the decoding of them exhibited mostly no difference to FFmpeg.
͏ .
͏ Which means the abnormal parsing is likely specific to your apps.
comment:7 by , 9 months ago
VirtualDub:
x265-params "open-gop=0" == no problems, all OK
-crf 19 -use_editlist 0 == 1 frame off here and there
Vegas (H265 legacy driver):
x265-params "open-gop=0" == cuts out the first two frames, so it only sees 498 frames
-crf 19 -use_editlist 0 == no problems
Vegas (H265 normal driver) + Premiere + Resolve: no problems with both files
It seems I was checking in two programs that are causing different problems :/. It's strange, because VirtualDub uses the ffmpeg libraries. I've reported the problem.
Thanks for the reply, everything seems to be fine.
Should I close the ticket?
comment:8 by , 9 months ago
| Keywords: | libx265 OGOP mp4 → mp4 libx265 OGOP |
|---|---|
| Resolution: | → wontfix |
| Status: | new → closed |
͏ What about using both?
͏ -x265-params "open-gop=0" -use_editlist 0
͏ This is fundamentally core definition issues of MP4 and H.265.
͏ Beyond what FFmpeg could fix.
comment:9 by , 9 months ago
Yes, that also works correctly.
What is the root cause of such problems (just out of curiosity)?
Is it better to use AV1 (for MP4 containers)?
comment:10 by , 9 months ago
͏ That's an issue of great complexity.
͏ None of the contemporary codecs/containers, are adequately designed toward the theoretical optimality:
͏ Some of them had alike mal-designs, that're causing various absurd issues.
͏ AV1 or not doesn't seem like the core determiner.
͏ Practical workaround:
͏ |*| Don't use OGOP as the concept is buggy.
͏ |*| Avoid MP4 editlist whenever applicable.



Changing the codec to AV1 also eliminates the problem.