Corrupt bitstream using x.265 3.3+1 and -preset slower

Issue #538 new
Michael Quinn created an issue

Here is the set of commands I use - I first do a crf encode as pass 1, then a pass 2 using the bitrate.
This works fine with preset medium and preset slow (I'm testing veryslow right now). However, with preset slower, there are pixellation artifacts all over the place..... (using 3.3+1 version). I've tried this on numerous HDR 4K encodes, and it's a consistent problem. (This example is the first 3 minutes of the 2009 Star Trek). Also of note - the output of the crf encode is fine - it’s only the output of the bitrate pass 2 that is messed up. This is using windows 10 on an i7-4770k CPU.

:_DragInstall\ffmpeg.exe -i ".\Star.Trek-001.mkv" -f rawvideo -pixel_format yuv420p10le -an -sn - 2> nul | C:_Draginstall\x265-3.3+1-g554c.exe --input - --input-depth 10 --input-res 3840x2160 --input-csp 1 --fps 24000/1001 --preset slower --analysis-reuse-file "C:\mux\Star.Trek-001.out.analyis1" --chromaloc 2 --colormatrix bt2020nc --transfer smpte2084 --colorprim bt2020 --hdr-opt --master-display G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,50) --crf 19 --no-slow-firstpass --multi-pass-opt-analysis --multi-pass-opt-distortion --multi-pass-opt-rps --pass 1 --stats "C:\mux\Star.Trek-001.out.stats" -o "C:\mux\Star.Trek-001.out.tmp.mp4"
yuv [info]: 3840x2160 fps 24000/1001 i420p10 unknown frame count
raw [info]: output file: C:\mux\Star.Trek-001.out.tmp.mp4
x265 [info]: HEVC encoder version 3.3+1-g554c887ac
x265 [info]: build info [Windows][MSVC 1924][64 bit] 10bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [warning]: Turning on repeat-headers for HDR compatibility
x265 [info]: Main 10 profile, Level-5 (Main tier)
x265 [info]: Thread pool created using 12 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(34 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 3 inter / 3 intra
x265 [info]: ME / range / subpel / merge : dia / 57 / 2 / 1
x265 [info]: Keyframe min / max / scenecut / bias : 23 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 40 / 8 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 1
x265 [info]: References / ref-limit cu / depth : 1 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : CRF-19.0 / 0.60
x265 [info]: tools: limit-modes rd=2 psy-rd=2.00 rdoq=2 psy-rdoq=1.00
x265 [info]: tools: early-skip rskip limit-tu=4 signhide tmvp b-intra
x265 [info]: tools: fast-intra strong-intra-smoothing deblock sao stats-write
x265 [info]: frame I: 43, Avg QP:21.24 kb/s: 25282.95
x265 [info]: frame P: 1457, Avg QP:22.21 kb/s: 12446.60
x265 [info]: frame B: 2832, Avg QP:25.29 kb/s: 6189.75
x265 [info]: Weighted P-Frames: Y:3.0% UV:2.4%
x265 [info]: Weighted B-Frames: Y:10.1% UV:6.8%
x265 [info]: consecutive B-frames: 36.1% 16.0% 10.5% 15.1% 13.1% 5.5% 1.3% 0.9% 1.6%

encoded 4332 frames in 1144.22s (3.79 fps), 8483.66 kb/s, Avg QP:24.22
Can't extract bitrate from file C:\mux\Star.Trek-001.out.q19r.p1.mp4 - trying 2nd method
191714349
Encoding pass 2 with bitrate = 8487
C:_DragInstall\ffmpeg.exe -i ".\Star.Trek-001.mkv" -f rawvideo -pixel_format yuv420p10le -an -sn - 2> nul | C:_Draginstall\x265-3.3+1-g554c.exe --input - --input-depth 10 --input-res 3840x2160 --input-csp 1 --fps 24000/1001 --preset slower --analysis-reuse-file "C:\mux\Star.Trek-001.out.analyis1" --chromaloc 2 --colormatrix bt2020nc --transfer smpte2084 --colorprim bt2020 --hdr-opt --master-display G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,50) --bitrate 8487 --multi-pass-opt-analysis --multi-pass-opt-distortion --multi-pass-opt-rps --pass 2 --stats "C:\mux\Star.Trek-001.out.stats" -o "C:\mux\Star.Trek-001.out.tmp.mp4"
yuv [info]: 3840x2160 fps 24000/1001 i420p10 unknown frame count
raw [info]: output file: C:\mux\Star.Trek-001.out.tmp.mp4
x265 [info]: HEVC encoder version 3.3+1-g554c887ac
x265 [info]: build info [Windows][MSVC 1924][64 bit] 10bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [warning]: Turning on repeat-headers for HDR compatibility
x265 [info]: Main 10 profile, Level-5 (Main tier)
x265 [info]: Thread pool created using 12 threads
x265 [info]: Slices : 1
x265 [info]: frame threads / pool features : 3 / wpp(34 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 3 inter / 3 intra
x265 [info]: ME / range / subpel / merge : star / 57 / 4 / 4
x265 [info]: Keyframe min / max / scenecut / bias : 23 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt : 40 / 8 / 2
x265 [info]: b-pyramid / weightp / weightb : 1 / 1 / 1
x265 [info]: References / ref-limit cu / depth : 5 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress : ABR-8487 kbps / 0.60
x265 [info]: tools: rect amp limit-modes rd=6 psy-rd=2.00 rdoq=2 psy-rdoq=1.00
x265 [info]: tools: rskip limit-tu=4 signhide tmvp b-intra
x265 [info]: tools: strong-intra-smoothing deblock sao stats-read
x265 [info]: frame I: 43, Avg QP:20.68 kb/s: 27379.49
x265 [info]: frame P: 1457, Avg QP:22.48 kb/s: 12252.87
x265 [info]: frame B: 2832, Avg QP:25.25 kb/s: 6245.61
x265 [info]: Weighted P-Frames: Y:3.0% UV:2.4%
x265 [info]: Weighted B-Frames: Y:10.1% UV:6.8%
x265 [info]: consecutive B-frames: 36.1% 16.0% 10.5% 15.1% 13.1% 5.5% 1.3% 0.9% 1.6%
x265 [info]: RPS in SPS: 3737 frames (86.27%), RPS not in SPS: 595 frames (13.73%)

encoded 4332 frames in 5162.24s (0.84 fps), 8475.83 kb/s, Avg QP:24.27

Comments (5)

  1. Michael Quinn reporter

    I think I see the issue - slower uses tu-limit 4, which is not guaranteed to be the same between passes with analysis data - that must be what’s happening here - I’m guessing if I set tu-limit to 0, it will be ok (everything but slower seems to have tu-limit set to 0 by default)

  2. Michael Quinn reporter

    preset slower and veryslow both have this issue, and does not seem to be related to limit-tu - I used limit-tu 0 and set the 2 inter/intras to 1, and it still occurs.

  3. Michael Quinn reporter

    This also occurs if I use --bitrate instead of --crf in the first pass, so it seems kind of bad.

  4. Michael Quinn reporter

    So, ultimately the issue boils down to something about --no-slow-firstpass. If I get rid of this option, the problem goes away.

  5. Log in to comment