h264 & h265 CRF0 "lossless" produces heavy artifacts

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
pulp_user
Posts: 2
Joined: Thu Jan 24, 2019 9:43 pm

h264 & h265 CRF0 "lossless" produces heavy artifacts

Post by pulp_user » Thu Jan 24, 2019 10:31 pm

Description of problem or question:
I was encoding my Collectors Edition Blu-Ray-Rip of Your Name (2016) in h265. The movie looks mostly undistinguishable from the source, with one exception: During 47:47 - 47:53 of the movie, completly static parts of the background (this is an anime, so and there is literally no pixel changing in the background) suddenly "flickers" about once a second. I tried 2 different versions of Handbrake various CRF values in h264(x264) and h265(x265, also in 10-bit), including CRF 0 in both, various encoding speeds, encoding in 2-Pass avg-birate-mode with a bitrate of 60,000 and also encoding in MPEG-2 with the same result.

The Source video is 33 Mb/s h264 MPEG-4 AVC ripped straight from the Blu-Ray using MakeMKV. It does not have these artifacts.

To rule out that the decoder of VLC is playing jokes on me, I even uploaded the short clip to Youtube (https://youtu.be/lDJolTdWFVo). Even after Youtube-Encdoding the artifact is still there, so it has to be in the actual file.

I normally would not lose my mind over small artifacts since encoders may take suboptimal choices once in a while, but RF0 in h264 is supposed to be lossless, so that would make it a bug. I also can't comprehend why this happens in the completly static part of the scene. Maybe this is just user error, but I checked everything like 4 times by now, so I am not going to find it on my own.

Steps to reproduce the problem (If Applicable):
Encode 47:47-47:53 of Your Name (2016).

HandBrake version (e.g., 1.0.0):
1st version:
Nightly 20181003200506-cee90c5-master(2018100501) - 64 bit

2nd version:
1.2.0 (2018121700)

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows 10 Education

HandBrake Activity Log ***required*** (see How-to get an activity log)

Code: Select all

HandBrake 1.2.0 (2018121700)
OS: Microsoft Windows NT 10.0.17134.0
Ram: 16245 MB, 
GPU Information:
  NVIDIA GeForce GTX 1070 - 25.21.14.1735
  Intel(R) HD Graphics 4600 - 20.19.15.4835
Screen: 1920x1080
Temp Dir: C:\Users\Simon\AppData\Local\Temp\
Install Dir: G:\HandBrake 1.2.0
Data Dir: C:\Users\Simon\AppData\Roaming\HandBrake

-------------------------------------------


# Starting Encode ...

[23:13:31] hb_init: starting libhb thread
[23:13:31] 1 job(s) to process
[23:13:31] json job:
{
  "Audio": {
    "AudioList": [],
    "CopyMask": [
      "copy:aac",
      "copy:ac3",
      "copy:dtshd",
      "copy:dts",
      "copy:eac3",
      "copy:flac",
      "copy:mp3",
      "copy:truehd"
    ],
    "FallbackEncoder": "ac3"
  },
  "Destination": {
    "ChapterList": [],
    "ChapterMarkers": false,
    "AlignAVStart": false,
    "File": "G:\\Your Name Rip-120.m4v",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": false
    },
    "Mux": "mp4"
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 4,
        "Settings": {
          "mode": "7"
        }
      },
      {
        "ID": 3,
        "Settings": {
          "block-height": "16",
          "block-thresh": "40",
          "block-width": "16",
          "filter-mode": "2",
          "mode": "3",
          "motion-thresh": "1",
          "spatial-metric": "2",
          "spatial-thresh": "1"
        }
      },
      {
        "ID": 11,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "1080",
          "width": "1920"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "0"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "time",
      "Start": 258030000,
      "End": 258570000
    },
    "Title": 1,
    "Path": "G:\\Your Name Rip.mkv"
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": false,
      "Forced": false
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "x264",
    "Level": "4.0",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "",
    "Preset": "placebo",
    "Profile": "main",
    "Quality": 0.0,
    "QSV": {
      "Decode": false,
      "AsyncDepth": 0
    }
  }
}
[23:13:31] CPU: Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz
[23:13:31]  - Intel microarchitecture Haswell
[23:13:31]  - logical processor count: 4
[23:13:31] Intel Quick Sync Video support: yes
[23:13:31]  - Intel Media SDK hardware: API 1.20 (minimum: 1.3)
[23:13:31]  - H.264 encoder: yes
[23:13:31]     - preferred implementation: hardware (any) via D3D11
[23:13:31]     - capabilities (hardware):  breftype icq+la+i+downs vsinfo opt1 opt2+mbbrc+extbrc+trellis+ib_adapt+nmpslice
[23:13:31]  - H.265 encoder: no
[23:13:31] hb_scan: path=G:\Your Name Rip.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:323: failed opening UDF image G:\Your Name Rip.mkv
src/libbluray/disc/disc.c:424: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:424: error opening file BDMV\BACKUP\index.bdmv
[23:13:31] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.0
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[23:13:31] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'G:\Your Name Rip.mkv':
  Metadata:
    title           : Your Name
    encoder         : libmakemkv v1.14.2 (1.3.5/1.4.7) win(x64-release)
    creation_time   : 2019-01-21T14:01:02.000000Z
  Duration: 01:47:19.13, start: 0.000000, bitrate: 43237 kb/s
    Chapter #0:0: start 0.000000, end 539.125000
    Metadata:
      title           : Chapter 01
    Chapter #0:1: start 539.125000, end 1063.791667
    Metadata:
      title           : Chapter 02
    Chapter #0:2: start 1063.791667, end 1646.750000
    Metadata:
      title           : Chapter 03
    Chapter #0:3: start 1646.750000, end 2267.083333
    Metadata:
      title           : Chapter 04
    Chapter #0:4: start 2267.083333, end 2773.583333
    Metadata:
      title           : Chapter 05
    Chapter #0:5: start 2773.583333, end 3200.541667
    Metadata:
      title           : Chapter 06
    Chapter #0:6: start 3200.541667, end 3840.833333
    Metadata:
      title           : Chapter 07
    Chapter #0:7: start 3840.833333, end 4365.791667
    Metadata:
      title           : Chapter 08
    Chapter #0:8: start 4365.791667, end 4982.166667
    Metadata:
      title           : Chapter 09
    Chapter #0:9: start 4982.166667, end 5563.666667
    Metadata:
      title           : Chapter 10
    Chapter #0:10: start 5563.666667, end 6090.583333
    Metadata:
      title           : Chapter 11
    Chapter #0:11: start 6090.583333, end 6439.125000
    Metadata:
      title           : Chapter 12
    Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn, 48 tbc
    Metadata:
      title           : h264 Blu-Ray untouched
      BPS-eng         : 33008635
      DURATION-eng    : 01:47:19.125000000
      NUMBER_OF_FRAMES-eng: 154539
      NUMBER_OF_BYTES-eng: 26568341307
      SOURCE_ID-eng   : 001011
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:1(deu): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), s32p (24 bit) (default)
    Metadata:
      title           : German DTS-HD MA
      BPS-eng         : 3589643
      DURATION-eng    : 01:47:19.136000000
      NUMBER_OF_FRAMES-eng: 603669
      NUMBER_OF_BYTES-eng: 2889275060
      SOURCE_ID-eng   : 001100
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:2(deu): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
    Metadata:
      title           : German DTS
      BPS-eng         : 1509000
      DURATION-eng    : 01:47:19.136000000
      NUMBER_OF_FRAMES-eng: 603669
      NUMBER_OF_BYTES-eng: 1214582028
      SOURCE_ID-eng   : 001100
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:3(jpn): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), s32p (24 bit)
    Metadata:
      title           : Japanese DTS-HD MA
      BPS-eng         : 3585040
      DURATION-eng    : 01:47:19.136000000
      NUMBER_OF_FRAMES-eng: 603669
      NUMBER_OF_BYTES-eng: 2885570176
      SOURCE_ID-eng   : 001101
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:4(jpn): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
    Metadata:
      title           : Japanese DTS
      BPS-eng         : 1509000
      DURATION-eng    : 01:47:19.136000000
      NUMBER_OF_FRAMES-eng: 603669
      NUMBER_OF_BYTES-eng: 1214582028
      SOURCE_ID-eng   : 001101
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:5(deu): Subtitle: hdmv_pgs_subtitle
    Metadata:
      title           : German Full
      BPS-eng         : 28546
      DURATION-eng    : 01:45:35.979166666
      NUMBER_OF_FRAMES-eng: 2401
      NUMBER_OF_BYTES-eng: 22608606
      SOURCE_ID-eng   : 001200
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:6(deu): Subtitle: hdmv_pgs_subtitle
    Metadata:
      title           : German Forced
      BPS-eng         : 709
      DURATION-eng    : 01:37:49.812500000
      NUMBER_OF_FRAMES-eng: 62
      NUMBER_OF_BYTES-eng: 520926
      SOURCE_ID-eng   : 001201
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
    Stream #0:7(deu): Subtitle: hdmv_pgs_subtitle
    Metadata:
      title           : German Forced
      BPS-eng         : 780
      DURATION-eng    : 01:29:00.020833333
      NUMBER_OF_FRAMES-eng: 60
      NUMBER_OF_BYTES-eng: 520856
      SOURCE_ID-eng   : 001201
      _STATISTICS_WRITING_APP-eng: MakeMKV v1.14.2 win(x64-release)
      _STATISTICS_WRITING_DATE_UTC-eng: 2019-01-21 14:01:02
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
[23:13:31] scan: decoding previews for title 1
[23:13:31] scan: audio 0x1: dca, rate=48000Hz, bitrate=1 Deutsch (DTS-HD MA) (5.1 ch)
[23:13:31] scan: audio 0x2: dca, rate=48000Hz, bitrate=1536000 Deutsch (DTS) (5.1 ch)
[23:13:31] scan: audio 0x3: dca, rate=48000Hz, bitrate=1 ??? (DTS-HD MA) (5.1 ch)
[23:13:31] scan: audio 0x4: dca, rate=48000Hz, bitrate=1536000 ??? (DTS) (5.1 ch)
[23:13:33] scan: 10 previews, 1920x1080, 24.000 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[23:13:33] scan: supported video decoders: avcodec qsv
[23:13:33] libhb: scan thread found 1 valid title(s)
[23:13:33] starting job
[23:13:33] decomb filter thread started for segment 0
[23:13:33] decomb filter thread started for segment 1
[23:13:33] decomb filter thread started for segment 2
[23:13:33] decomb filter thread started for segment 3
[23:13:33] decomb check thread started for segment 3
[23:13:33] decomb check thread started for segment 1
[23:13:33] decomb check thread started for segment 2
[23:13:33] decomb check thread started for segment 0
[23:13:33] mask filter thread started for segment 3
[23:13:33] mask erode thread started for segment 0
[23:13:33] mask filter thread started for segment 2
[23:13:33] mask filter thread started for segment 0
[23:13:33] mask filter thread started for segment 1
[23:13:33] mask erode thread started for segment 1
[23:13:33] mask dilate thread started for segment 0
[23:13:33] mask dilate thread started for segment 1
[23:13:33] mask erode thread started for segment 2
[23:13:33] mask erode thread started for segment 3
[23:13:33] mask dilate thread started for segment 2
[23:13:33] mask dilate thread started for segment 3
[23:13:33] yadif thread started for segment 0
[23:13:33] yadif thread started for segment 2
[23:13:33] yadif thread started for segment 1
[23:13:33] yadif thread started for segment 3
[23:13:33] job configuration:
[23:13:33]  * source
[23:13:33]    + G:\Your Name Rip.mkv
[23:13:33]    + title 1, start 00:47:47.00 stop 00:47:53.00
[23:13:33]    + container: matroska,webm
[23:13:33]    + data rate: 43237 kbps
[23:13:33]  * destination
[23:13:33]    + G:\Your Name Rip-120.m4v
[23:13:33]    + container: MPEG-4 (libavformat)
[23:13:33]  * video track
[23:13:33]    + decoder: h264
[23:13:33]    + filters
[23:13:33]      + Comb Detect (mode=3:spatial-metric=2:motion-thresh=1:spatial-thresh=1:filter-mode=2:block-thresh=40:block-width=16:block-height=16)
[23:13:33]      + Decomb (mode=39)
[23:13:33]      + Framerate Shaper (mode=0)
[23:13:33]        + frame rate: same as source (around 24.000 fps)
[23:13:33]      + Crop and Scale (width=1920:height=1080:crop-top=0:crop-bottom=0:crop-left=0:crop-right=0)
[23:13:33]        + source: 1920 * 1080, crop (0/0/0/0): 1920 * 1080, scale: 1920 * 1080
[23:13:33]    + Output geometry
[23:13:33]      + storage dimensions: 1920 x 1080
[23:13:33]      + pixel aspect ratio: 1 : 1
[23:13:33]      + display dimensions: 1920 x 1080
[23:13:33]    + encoder: H.264 (libx264)
[23:13:33]      + preset:  placebo
[23:13:33]      + profile: main
[23:13:33]      + level:   4.0
[23:13:33]      + quality: 0.00 (RF)
[23:13:33]      + color profile: 1-1-1
[23:13:33] sync: expecting 168 video frames
[23:13:33] encx264: min-keyint: 24, keyint: 240
[23:13:33] encx264: encoding at constant RF 0.000000
[23:13:33] apply_h264_profile [warning]: lossless requires high444 profile, disabling
[23:13:33] encx264: unparsed options: level=4.0:ref=4:bframes=16:b-adapt=2:direct=auto:analyse=all:8x8dct=0:me=tesa:merange=24:subme=11:trellis=2:fast-pskip=0:vbv-bufsize=25000:vbv-maxrate=20000:rc-lookahead=60
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile Main, level 4.0, 4:2:0, 8-bit
[23:13:33] sync: first pts video is 0
[23:13:51] sync: reached video pts 540000, exiting early
[23:15:00] work: average encoding speed for job is 8.152174 fps
[23:15:00] comb detect: heavy 2 | light 9 | uncombed 133 | total 144
[23:15:00] decomb: deinterlaced 2 | blended 9 | unfiltered 133 | total 144
[23:15:00] vfr: lost time: 0 (0 frames)
[23:15:00] vfr: gained time: 0 (0 frames) (0 not accounted for)
[23:15:00] h264-decoder done: 5438 frames, 0 decoder errors
[23:15:00] sync: got 144 frames, 168 expected
[23:15:00] sync: framerate min 24.000 fps, max 24.000 fps, avg 24.000 fps
x264 [info]: frame I:2     Avg QP:12.71  size:631994
x264 [info]: frame P:41    Avg QP: 9.75  size:285159
x264 [info]: frame B:101   Avg QP:13.81  size: 27114
x264 [info]: consecutive B-frames:  2.1%  5.6% 50.0%  8.3% 20.8%  8.3%  4.9%  0.0%  0.0%  0.0%  0.0%  0.0%  0.0%  0.0%  0.0%  0.0%  0.0%
x264 [info]: mb I  I16..4: 14.6%  0.0% 85.4%
x264 [info]: mb P  I16..4:  2.9%  0.0%  5.5%  P16..4: 50.6% 12.7% 16.3%  4.7%  3.0%    skip: 4.4%
x264 [info]: mb B  I16..4:  0.8%  0.0%  0.8%  B16..8: 29.6%  8.8%  2.8%  direct: 5.4%  skip:51.7%  L0:32.8% L1:56.4% BI:10.8%
x264 [info]: direct mvs  spatial:97.0% temporal:3.0%
x264 [info]: coded y,uvDC,uvAC intra: 94.3% 99.4% 98.5% inter: 26.7% 32.6% 28.1%
x264 [info]: i16 v,h,dc,p: 12% 18% 29% 42%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 15% 12%  8% 10%  9%  9%  9% 13%
x264 [info]: i8c dc,h,v,p: 66% 16% 11%  7%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: ref P L0: 79.3%  0.9% 13.7%  5.7%  0.4%
x264 [info]: ref B L0: 82.4% 14.2%  3.4%
x264 [info]: ref B L1: 97.7%  2.3%
x264 [info]: kb/s:20925.41
[23:15:00] mux: track 0, 144 frames, 15693970 bytes, 20780.98 kbps, fifo 128
[23:15:00] libhb: work result = 0

# Encode Completed ...



User avatar
s55
HandBrake Team
Posts: 9378
Joined: Sun Dec 24, 2006 1:05 pm

Re: h264 & h265 CRF0 "lossless" produces heavy artifacts

Post by s55 » Thu Jan 24, 2019 10:35 pm

It's likely an artifact of filtering. Try turning off comb detect and deinterlacing.

pulp_user
Posts: 2
Joined: Thu Jan 24, 2019 9:43 pm

Re: h264 & h265 CRF0 "lossless" produces heavy artifacts

Post by pulp_user » Thu Jan 24, 2019 10:51 pm

That was fast. You were totally right, it was deinterlacing. Thank you very much!

Post Reply