H264 RF 0 in Handbrake is not truly lossless

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
Snelso91
Posts: 4
Joined: Wed Jan 26, 2022 11:40 pm

H264 RF 0 in Handbrake is not truly lossless

Post by Snelso91 »

Description of problem or question:

When I encode a H265 VFR source file to H264 CFR with RF 0, handbrake does not produce a truly lossless file.
I have also tried to use qp=0 in the advanced options box at the same time as RF 0 but this does not change the output file. Conversely, using the -qp 0 option in ffmpeg does produce a truly lossless encode to H264 (the -x265-params lossless=1 flag also works for producing a truly lossless H265 file in ffmpeg).
Whilst the handbrake encode looks close to the original, it is clear when capturing a png of a specific frame on both the source and the encode and then zooming to 200% with nearest neighbour scaling that some blurring is occurring that was not present in the source file.

To illustrate my point I've uploaded an image album showing the difference between a crop of the same frame encoded with each method.

How can I produce a truly lossless H264 or H265 file in Handbrake like I can with ffmpeg?


Steps to reproduce the problem (If Applicable):
  1. Load a clip into handbrake and encode with H264 regular (not 10 bit or GPU) with constant framerate, ultrafast preset and RF=0 quality.
  2. Line up two frames from the source and encoded video in a video viewer of your choice and take a screenshot of each and save as PNG (or better yet extract a PNG of the source frame if you are using a player such as PotPlayer).
  3. Zoom in to 200% or so and you will see that slight blurring has been added in the encode vs the source.

HandBrake version (e.g., 1.0.0):

HandBrake 1.5.1 (2022011000)


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

OS: Microsoft Windows NT 10.0.19044.0


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

Code: Select all

Source RF0_encode_01.26.2022 23-55-42.txt:

HandBrake 1.5.1 (2022011000)
OS: Microsoft Windows NT 10.0.19044.0
CPU: AMD Ryzen 7 3700X 8-Core Processor             
Ram: 32711 MB, 
GPU Information:
  NVIDIA GeForce RTX 3060 - 30.0.14.9729
Screen: 2560x1440
Temp Dir: C:\Users\User\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake\
Data Dir: C:\Users\User\AppData\Roaming\HandBrake

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

 # Starting Encode ...

[23:55:42] base preset: Lossless Encoding (Modified)
[23:55:42] Remote Process started with Process ID: 41476 using port: 9037. Max Allowed Instances: 1
[23:55:42] Worker: Starting HandBrake Engine ...
[23:55:42] Worker: Starting Web Server on port 9037 ...
[23:55:43] Worker: Disconnected worker monitoring enabled!
[23:55:43] Compile-time hardening features are enabled
[23:55:43] hb_init: starting libhb thread
[23:55:43] Starting work at: Wed Jan 26 23:55:43 2022
[23:55:43] 1 job(s) to process
[23:55:43] json job:
{
  "Audio": {
    "AudioList": [
      {
        "DRC": 0,
        "Encoder": "copy:aac",
        "Gain": 0,
        "Mixdown": -1,
        "NormalizeMixLevel": false,
        "Samplerate": 0,
        "Track": 0,
        "DitherMethod": 0
      }
    ],
    "CopyMask": [
      "copy:aac",
      "copy:ac3",
      "copy:dtshd",
      "copy:dts",
      "copy:eac3",
      "copy:flac",
      "copy:mp3",
      "copy:truehd",
      "copy:mp2"
    ],
    "FallbackEncoder": "ac3"
  },
  "Destination": {
    "ChapterList": [
      {
        "Name": "Chapter 1"
      }
    ],
    "ChapterMarkers": true,
    "AlignAVStart": true,
    "File": "C:\\Users\\User\\Videos\\Game Capture\\GAME OF THE YEAR 420 BLAZE IT\\Source RF0.mp4",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": true
    },
    "Mux": "av_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": 13,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "1080",
          "width": "1920"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "1",
          "rate": "27000000/450000"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 1
    },
    "Title": 1,
    "Path": "C:\\Users\\User\\Videos\\Game Capture\\GAME OF THE YEAR 420 BLAZE IT\\Source.mp4"
  },
  "Subtitle": {
    "Search": {
      "Burn": true,
      "Default": false,
      "Enable": true,
      "Forced": true
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "x264",
    "Level": "auto",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "",
    "Preset": "ultrafast",
    "Profile": "auto",
    "Quality": 0,
    "QSV": {
      "Decode": false
    }
  }
}
[23:55:43] CPU:
[23:55:43]  - logical processor count: 16
[23:55:43] Intel Quick Sync Video support: no
[23:55:43] hb_scan: path=C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:333: failed opening UDF image C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4
src/libbluray/disc/disc.c:437: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:437: error opening file BDMV\BACKUP\index.bdmv
src/libbluray/bluray.c:2646: nav_get_title_list(C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4\) failed
[23:55:43] bd: not a bd - trying as a stream/file instead
libdvdread: Encrypted DVD support unavailable.
libdvdreadlibdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[23:55:43] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.45.100
  Duration: 00:03:24.10, start: 0.000000, bitrate: 63214 kb/s
  Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 62817 kb/s, 59.98 fps, 60 tbr, 90k tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 386 kb/s (default)
    Metadata:
      handler_name    : Stereo
      vendor_id       : [0][0][0][0]
[23:55:43] scan: decoding previews for title 1
[23:55:43] scan: audio 0x1: aac, rate=48000Hz, bitrate=386646 Unknown (AAC LC) (2.0 ch) (386 kbps)
[23:55:44] scan: 10 previews, 1920x1080, 59.980 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1, color profile: 1-1-1, chroma location: left
[23:55:44] libhb: scan thread found 1 valid title(s)
[23:55:44] Skipping subtitle scan.  No suitable subtitle tracks.
[23:55:44] Starting Task: Encoding Pass
[23:55:44] Skipping crop/scale filter
[23:55:44] work: only 1 chapter, disabling chapter markers
[23:55:44] job configuration:
[23:55:44]  * source
[23:55:44]    + C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4
[23:55:44]    + title 1, chapter(s) 1 to 1
[23:55:44]    + container: mov,mp4,m4a,3gp,3g2,mj2
[23:55:44]    + data rate: 63214 kbps
[23:55:44]  * destination
[23:55:44]    + C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source RF0.mp4
[23:55:44]    + container: MPEG-4 (libavformat)
[23:55:44]      + optimized for HTTP streaming (fast start)
[23:55:44]      + align initial A/V stream timestamps
[23:55:44]  * video track
[23:55:44]    + decoder: hevc 8-bit (yuv420p)
[23:55:44]      + bitrate 62817 kbps
[23:55:44]    + filters
[23:55:44]      + 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:55:44]      + Decomb (mode=39)
[23:55:44]      + Framerate Shaper (mode=1:rate=27000000/450000)
[23:55:44]        + frame rate: 59.980 fps -> constant 60.000 fps
[23:55:44]    + Output geometry
[23:55:44]      + storage dimensions: 1920 x 1080
[23:55:44]      + pixel aspect ratio: 1 : 1
[23:55:44]      + display dimensions: 1920 x 1080
[23:55:44]    + encoder: H.264 (libx264)
[23:55:44]      + preset:  ultrafast
[23:55:44]      + profile: auto
[23:55:44]      + level:   auto
[23:55:44]      + quality: 0.00 (RF)
[23:55:44]      + color profile: 1-1-1
[23:55:44]      + chroma location: left
[23:55:44]  * audio track 1
[23:55:44]    + decoder: Unknown (AAC LC) (2.0 ch) (386 kbps) (track 1, id 0x1)
[23:55:44]      + bitrate: 386 kbps, samplerate: 48000 Hz
[23:55:44]    + AAC Passthru
[23:55:44] sync: expecting 12241 video frames
[23:55:44] encx264: min-keyint: 60, keyint: 600
[23:55:44] encx264: encoding at constant RF 0.000000
[23:55:44] encx264: unparsed options: ref=1:scenecut=0:bframes=0:no-deblock=1:cabac=0:analyse=none:8x8dct=0:weightp=0:me=dia:subme=0:mixed-refs=0:trellis=0:aq-mode=0:mbtree=0:rc-lookahead=0
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High 4:4:4 Predictive, level 4.2, 4:2:0, 8-bit
[23:55:44] sync: first pts audio 0x1 is 0
[23:55:44] sync: first pts video is 1890
[23:55:44] sync: "Chapter 1" (1) at frame 1 time 1890
[23:57:08] reader: done. 1 scr changes
[23:57:08] work: average encoding speed for job is 144.746048 fps
[23:57:08] comb detect: heavy 784 | light 2984 | uncombed 8473 | total 12241
[23:57:08] decomb: deinterlaced 784 | blended 2984 | unfiltered 8473 | total 12241
[23:57:08] vfr: 12245 frames output, 0 dropped and 4 duped for CFR/PFR
[23:57:08] vfr: lost time: 0 (0 frames)
[23:57:08] vfr: gained time: 0 (0 frames) (0 not accounted for)
[23:57:08] aac-decoder done: 9567 frames, 0 decoder errors
[23:57:08] hevc-decoder done: 12241 frames, 0 decoder errors
[23:57:08] sync: got 12241 frames, 12241 expected
[23:57:08] sync: framerate min 30.612 fps, max 60.000 fps, avg 59.978 fps
x264 [info]: frame I:21    Avg QP: 0.00  size:913076
x264 [info]: frame P:12224 Avg QP: 0.00  size:770004
x264 [info]: mb I  I16..4: 100.0%  0.0%  0.0%
x264 [info]: mb P  I16..4: 65.3%  0.0%  0.0%  P16..4: 31.2%  0.0%  0.0%  0.0%  0.0%    skip: 3.5%
x264 [info]: coded y,uvDC,uvAC intra: 88.7% 86.9% 86.7% inter: 80.3% 80.9% 80.8%
x264 [info]: i16 v,h,dc,p: 50% 49%  1%  0%
x264 [info]: i8c dc,h,v,p: 15% 47% 37%  0%
x264 [info]: kb/s:369719.91
[23:57:22] mux: track 0, 12245 frames, 9431708555 bytes, 369659.52 kbps, fifo 256
[23:57:22] mux: track 1, 9567 frames, 9864179 bytes, 386.61 kbps, fifo 256
[23:57:22] Finished work at: Wed Jan 26 23:57:22 2022
[23:57:22] libhb: work result = 0

 # Job Completed!



---------------------------------------------------------------------------------------------------------------------------------
Source RF0 qp_encode_01.26.2022 23-53-55.txt:

HandBrake 1.5.1 (2022011000)
OS: Microsoft Windows NT 10.0.19044.0
CPU: AMD Ryzen 7 3700X 8-Core Processor             
Ram: 32711 MB, 
GPU Information:
  NVIDIA GeForce RTX 3060 - 30.0.14.9729
Screen: 2560x1440
Temp Dir: C:\Users\User\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake\
Data Dir: C:\Users\User\AppData\Roaming\HandBrake

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

 # Starting Encode ...

[23:53:55] base preset: Lossless Encoding
[23:53:56] Remote Process started with Process ID: 12728 using port: 9037. Max Allowed Instances: 1
[23:53:56] Worker: Starting HandBrake Engine ...
[23:53:56] Worker: Starting Web Server on port 9037 ...
[23:53:56] Worker: Disconnected worker monitoring enabled!
[23:53:56] Compile-time hardening features are enabled
[23:53:56] hb_init: starting libhb thread
[23:53:56] Starting work at: Wed Jan 26 23:53:56 2022
[23:53:56] 1 job(s) to process
[23:53:56] json job:
{
  "Audio": {
    "AudioList": [
      {
        "DRC": 0,
        "Encoder": "copy:aac",
        "Gain": 0,
        "Mixdown": -1,
        "NormalizeMixLevel": false,
        "Samplerate": 0,
        "Track": 0,
        "DitherMethod": 0
      }
    ],
    "CopyMask": [
      "copy:aac",
      "copy:ac3",
      "copy:dtshd",
      "copy:dts",
      "copy:eac3",
      "copy:flac",
      "copy:mp3",
      "copy:truehd",
      "copy:mp2"
    ],
    "FallbackEncoder": "ac3"
  },
  "Destination": {
    "ChapterList": [
      {
        "Name": "Chapter 1"
      }
    ],
    "ChapterMarkers": true,
    "AlignAVStart": true,
    "File": "C:\\Users\\User\\Videos\\Game Capture\\GAME OF THE YEAR 420 BLAZE IT\\Source RF0 qp.mp4",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": true
    },
    "Mux": "av_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": 13,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "1080",
          "width": "1920"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "1",
          "rate": "27000000/450000"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 1
    },
    "Title": 1,
    "Path": "C:\\Users\\User\\Videos\\Game Capture\\GAME OF THE YEAR 420 BLAZE IT\\Source.mp4"
  },
  "Subtitle": {
    "Search": {
      "Burn": true,
      "Default": false,
      "Enable": true,
      "Forced": true
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "x264",
    "Level": "auto",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "qp=0:",
    "Preset": "ultrafast",
    "Profile": "auto",
    "Quality": 0,
    "QSV": {
      "Decode": false
    }
  }
}
[23:53:56] CPU:
[23:53:56]  - logical processor count: 16
[23:53:56] Intel Quick Sync Video support: no
[23:53:56] hb_scan: path=C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:333: failed opening UDF image C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4
src/libbluray/disc/disc.c:437: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:437: error opening file BDMV\BACKUP\index.bdmv
src/libbluray/bluray.c:2646: nav_get_title_list(C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4\) failed
[23:53:56] bd: not a bd - trying as a stream/file instead
libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't open file libdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
VIDEO_TS.IFO.
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[23:53:56] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf58.45.100
  Duration: 00:03:24.10, start: 0.000000, bitrate: 63214 kb/s
  Stream #0:0(und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 62817 kb/s, 59.98 fps, 60 tbr, 90k tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 386 kb/s (default)
    Metadata:
      handler_name    : Stereo
      vendor_id       : [0][0][0][0]
[23:53:56] scan: decoding previews for title 1
[23:53:56] scan: audio 0x1: aac, rate=48000Hz, bitrate=386646 Unknown (AAC LC) (2.0 ch) (386 kbps)
[23:53:57] scan: 10 previews, 1920x1080, 59.980 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1, color profile: 1-1-1, chroma location: left
[23:53:57] libhb: scan thread found 1 valid title(s)
[23:53:57] Skipping subtitle scan.  No suitable subtitle tracks.
[23:53:57] Starting Task: Encoding Pass
[23:53:57] Skipping crop/scale filter
[23:53:57] work: only 1 chapter, disabling chapter markers
[23:53:57] job configuration:
[23:53:57]  * source
[23:53:57]    + C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source.mp4
[23:53:57]    + title 1, chapter(s) 1 to 1
[23:53:57]    + container: mov,mp4,m4a,3gp,3g2,mj2
[23:53:57]    + data rate: 63214 kbps
[23:53:57]  * destination
[23:53:57]    + C:\Users\User\Videos\Game Capture\GAME OF THE YEAR 420 BLAZE IT\Source RF0 qp.mp4
[23:53:57]    + container: MPEG-4 (libavformat)
[23:53:57]      + optimized for HTTP streaming (fast start)
[23:53:57]      + align initial A/V stream timestamps
[23:53:57]  * video track
[23:53:57]    + decoder: hevc 8-bit (yuv420p)
[23:53:57]      + bitrate 62817 kbps
[23:53:57]    + filters
[23:53:57]      + 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:53:57]      + Decomb (mode=39)
[23:53:57]      + Framerate Shaper (mode=1:rate=27000000/450000)
[23:53:57]        + frame rate: 59.980 fps -> constant 60.000 fps
[23:53:57]    + Output geometry
[23:53:57]      + storage dimensions: 1920 x 1080
[23:53:57]      + pixel aspect ratio: 1 : 1
[23:53:57]      + display dimensions: 1920 x 1080
[23:53:57]    + encoder: H.264 (libx264)
[23:53:57]      + preset:  ultrafast
[23:53:57]      + options: qp=0:
[23:53:57]      + profile: auto
[23:53:57]      + level:   auto
[23:53:57]      + quality: 0.00 (RF)
[23:53:57]      + color profile: 1-1-1
[23:53:57]      + chroma location: left
[23:53:57]  * audio track 1
[23:53:57]    + decoder: Unknown (AAC LC) (2.0 ch) (386 kbps) (track 1, id 0x1)
[23:53:57]      + bitrate: 386 kbps, samplerate: 48000 Hz
[23:53:57]    + AAC Passthru
[23:53:57] sync: expecting 12241 video frames
[23:53:57] encx264: min-keyint: 60, keyint: 600
[23:53:57] encx264: encoding at constant RF 0.000000
[23:53:57] encx264: unparsed options: ref=1:scenecut=0:bframes=0:no-deblock=1:cabac=0:analyse=none:8x8dct=0:weightp=0:me=dia:subme=0:mixed-refs=0:trellis=0:aq-mode=0:mbtree=0:rc-lookahead=0
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High 4:4:4 Predictive, level 4.2, 4:2:0, 8-bit
[23:53:58] sync: first pts audio 0x1 is 0
[23:53:58] sync: first pts video is 1890
[23:53:58] sync: "Chapter 1" (1) at frame 1 time 1890
[23:55:27] reader: done. 1 scr changes
[23:55:27] work: average encoding speed for job is 135.420898 fps
[23:55:27] comb detect: heavy 784 | light 2984 | uncombed 8473 | total 12241
[23:55:27] decomb: deinterlaced 784 | blended 2984 | unfiltered 8473 | total 12241
[23:55:27] vfr: 12245 frames output, 0 dropped and 4 duped for CFR/PFR
[23:55:27] vfr: lost time: 0 (0 frames)
[23:55:27] vfr: gained time: 0 (0 frames) (0 not accounted for)
[23:55:27] aac-decoder done: 9567 frames, 0 decoder errors
[23:55:27] hevc-decoder done: 12241 frames, 0 decoder errors
[23:55:27] sync: got 12241 frames, 12241 expected
[23:55:27] sync: framerate min 30.612 fps, max 60.000 fps, avg 59.978 fps
x264 [info]: frame I:21    Avg QP: 0.00  size:913076
x264 [info]: frame P:12224 Avg QP: 0.00  size:770004
x264 [info]: mb I  I16..4: 100.0%  0.0%  0.0%
x264 [info]: mb P  I16..4: 65.3%  0.0%  0.0%  P16..4: 31.2%  0.0%  0.0%  0.0%  0.0%    skip: 3.5%
x264 [info]: coded y,uvDC,uvAC intra: 88.7% 86.9% 86.7% inter: 80.3% 80.9% 80.8%
x264 [info]: i16 v,h,dc,p: 50% 49%  1%  0%
x264 [info]: i8c dc,h,v,p: 15% 47% 37%  0%
x264 [info]: kb/s:369719.91
[23:55:41] mux: track 0, 12245 frames, 9431708555 bytes, 369659.52 kbps, fifo 256
[23:55:41] mux: track 1, 9567 frames, 9864179 bytes, 386.61 kbps, fifo 256
[23:55:41] Finished work at: Wed Jan 26 23:55:41 2022
[23:55:41] libhb: work result = 0

 # Job Completed!


Deleted User 11865

Re: H264 RF 0 in Handbrake is not truly lossless

Post by Deleted User 11865 »

You have some video filters enabled ;-)
Snelso91
Posts: 4
Joined: Wed Jan 26, 2022 11:40 pm

Re: H264 RF 0 in Handbrake is not truly lossless

Post by Snelso91 »

Rodeo wrote: Thu Jan 27, 2022 11:33 am You have some video filters enabled ;-)
Hi,

Could you be more specific about what I need to disable?
As far as I'm aware, I've left everything as default other than the things I said I changed (such as RF=0, qp=0, etc.) that were necessary to attempt to get the lossless result?
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: H264 RF 0 in Handbrake is not truly lossless

Post by Woodstock »

Code: Select all

[23:55:44]  * video track
[23:55:44]    + decoder: hevc 8-bit (yuv420p)
[23:55:44]      + bitrate 62817 kbps
[23:55:44]    + filters
[23:55:44]      + 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:55:44]      + Decomb (mode=39)
[23:55:44]      + Framerate Shaper (mode=1:rate=27000000/450000)
[23:55:44]        + frame rate: 59.980 fps -> constant 60.000 fps
You are decombing the video, which will alter it. You are changing the frame rate (a little).

"Lossless" (RF0) refers to encoding the video after it's been expanded from its previous compression, and the filters applied to it. It doesn't mean "nothing is lost from the original to the output".
Snelso91
Posts: 4
Joined: Wed Jan 26, 2022 11:40 pm

Re: H264 RF 0 in Handbrake is not truly lossless

Post by Snelso91 »

Thanks for clearing that up, I've just run it through again with deinterlace changed from the default decomb settings to "off" and the frames do look identical now so I think the original problem is solved.

However, one key point I don't quite understand is why is the decomb/deinterlacing filter being activated in the first place (and therefore introducing artefacts) when I am using the default settings for interlace detection, and the source file is quite clearly a progressive video?

If the deinterlace detection/decombing gets activated for most progressive videos and not just this one, why is the default setting for handbrake to use decombing at all if it reduces the quality for no reason?
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: H264 RF 0 in Handbrake is not truly lossless

Post by mduell »

Code: Select all

[23:55:27] comb detect: heavy 784 | light 2984 | uncombed 8473 | total 12241
[23:55:27] decomb: deinterlaced 784 | blended 2984 | unfiltered 8473 | total 12241
The decomb detection thinks it found combing, so it deinterlaced or blended some frames.

It generally works fine, or the impact is minimal, so compared with the alternative of not deinterlacing the vast quantities of interlaced material out there, it generates fewer user complaints to default it on for the presets most used with resolutions where interlacing is common.
Woodstock
Veteran User
Posts: 4614
Joined: Tue Aug 27, 2013 6:39 am

Re: H264 RF 0 in Handbrake is not truly lossless

Post by Woodstock »

Detected (but not real) combing can be subtle. Horizontal siding on buildings, slat-type blinds on background windows, even a scene where the camera pans across a number of CRT-type displays, all can fool Comb detect.

If I know the video is progressive, I disable Comb detect and deinterlace. If I know it is interlaced, I disable Comb detect, enable decomb=BoB, and set frame rate to "variable same as source" so the doubled frame rate works out. If I don't know... I assume DVD is interlaced, BD is progressive.

Fortunately, MOST "full HD" and higher resolution sources are 100% progressive. We won't talk about certain Japanese publishers, though. And treat "SD on BD" as just another DVD, just much bigger files.
Snelso91
Posts: 4
Joined: Wed Jan 26, 2022 11:40 pm

Re: H264 RF 0 in Handbrake is not truly lossless

Post by Snelso91 »

Thanks for the explanation - it's a bit frustrating that I've had it turned on until now and as a result making the quality worse/more blurry because of certain features in the video (since everything I've ever needed to encode with handbrake has been progressive), as I previously assumed the defaults would be able to properly differentiate between interlaced and progressive content and so progressive content would not be affected at all.

I think I'll follow your suggestion of just turning it off for all my presets, since as I said, all videos I've needed to encode over the years have been progressive, and obviously if I need deinterlacing for an actual interlaced video I can always activate it again in the future.
Post Reply