Can Handbrake encode HDR HEVC for 4k Blu-ray?

HandBrake for Mac 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
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

Description of problem or question:

I have been trying for weeks to get a way to put 4K footage from iPhone and other cameras into a 4k Blu-ray. That footage is not HDR, but because I'm an old nerd, I just wanted to see if I could. But until today I was exporting from FCPX a Prores file without the HDR information because I had no idea. So finally I came across and article from Apple showing that, and I added it to my project. So in case anyone is trying the same thing, this is the article: https://support.apple.com/guide/final-c ... d31dd2/mac

So after doing that, Media Info now sees that it contains HDR info:

Code: Select all

Video
ID                                       : 2
Format                                   : ProRes
Format version                           : Version 0
Format profile                           : 422 HQ
HDR format                               : SMPTE ST 2086, HDR10 compatible
Codec ID                                 : apch
Duration                                 : 22 min 56 s
Bit rate mode                            : Variable
Bit rate                                 : 651 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 23.976 (24000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 3.275
Stream size                              : 104 GiB (100%)
Title                                    : Core Media Video
Writing library                          : Apple
Encoded date                             : UTC 2022-07-12 22:27:07
Tagged date                              : UTC 2022-07-12 22:29:07
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant
Mastering display color primaries        : BT.2020
Mastering display luminance              : min: 0.0001 cd/m2, max: 1000 cd/m2
Maximum Content Light Level              : 1000 cd/m2
Maximum Frame-Average Light Level        : 800 cd/m2
But still, encoding that file with Handbrake using either VideoToolbox or x265 to HEVC doesn't produce an HDR file. At first it was confusing because I couldn't anywhere the correct usage for the additional parameters. I assumed it was like using the CLI, and the x265 documentation at https://x265.readthedocs.io/en/stable/cli.html shows all the parameters starting with --, as in "--hdr10," so I started by entering "--keyint 24, --uhd-bd, --aq-mode 2, --hdr10, --hdr10-opt", which then I saw on the log that it was unrecognized.

Then I tried all this from another website by a guy called Chris Griffin, who seems to know a lot: "-map 0 -c:v libx265 -x265-params hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:-crf 20 -preset veryfast -pix_fmt yuv420p10le"

That didn't work either. So now I'm trying this "uhd-bd=1:hdr=1:hdr-opt=1:repeat- headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" and I'll see the result in about 80 minutes, but if that doesn't work, I'm out of ideas.

Steps to reproduce the problem (If Applicable):

No steps, really. Just checking to see if it's possible.

HandBrake version (e.g., 1.0.0):

1.5.1 (2022011000) for macOS

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

macOS Monterey 12.4

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

Code: Select all

[16:15:31] macgui: Handbrake Version: 1.5.1 (2022011000)
[16:15:31] Compile-time hardening features are enabled
[16:15:31] hb_init: starting libhb thread
[16:15:31] thread 16d65f000 started ("libhb")
[16:15:38] macgui: ScanCore scanning titles with a duration of 10 seconds or more
[16:15:38] CPU: 
[16:15:38]  - logical processor count: 20
[16:15:38] hb_scan: path=(hidden for privacy), title_index=0
[16:15:38] thread 16d42f000 started ("scan")
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:333: failed opening UDF image (hidden for privacy)
disc.c:437: error opening file BDMV/index.bdmv
disc.c:437: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2646: nav_get_title_list((hidden for privacy)) failed
[16:15:38] bd: not a bd - trying as a stream/file instead
libdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[16:15:38] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '(hidden for privacy)':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2022-07-12T22:27:07.000000Z
    com.apple.quicktime.keywords: (hidden for privacy)
    com.apple.quicktime.description: (hidden for privacy)
    com.apple.quicktime.author: (hidden for privacy)
    com.apple.quicktime.displayname: (hidden for privacy)
    com.apple.quicktime.title: (hidden for privacy)
  Duration: 00:22:56.96, start: 0.000000, bitrate: 654025 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 66.024292
      Metadata:
        title           : Chapter 1
    Chapter #0:1: start 66.024292, end 141.808333
      Metadata:
        title           : Chapter 2
    Chapter #0:2: start 141.808333, end 235.401833
      Metadata:
        title           : Chapter 3
    Chapter #0:3: start 235.401833, end 325.867208
      Metadata:
        title           : Chapter 4
    Chapter #0:4: start 325.867208, end 611.193917
      Metadata:
        title           : Chapter 5
    Chapter #0:5: start 611.193917, end 789.121667
      Metadata:
        title           : Chapter 6
    Chapter #0:6: start 789.121667, end 1122.329542
      Metadata:
        title           : Chapter 7
    Chapter #0:7: start 1122.329542, end 1376.708667
      Metadata:
        title           : Chapter 8
    Chapter #0:8: start 1376.708667, end 1376.958917
      Metadata:
        title           : Chapter 9
  Stream #0:0(und): Audio: pcm_s24le (lpcm / 0x6D63706C), 48000 Hz, 2 channels, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Video: prores (HQ) (apch / 0x68637061), yuv422p10le(tv, bt2020nc/bt2020/smpte2084, progressive), 3840x2160, 651315 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : Apple ProRes 422 HQ
      timecode        : 00:00:00:00
    Side data:
      Mastering Display Metadata, has_primaries:1 has_luminance:1 r(0.7080,0.2920) g(0.1700,0.7970) b(0.1310 0.0460) wp(0.3127, 0.3290) min_luminance=0.000100, max_luminance=1000.000000
      Content Light Level Metadata, MaxCLL=1000, MaxFALL=800
  Stream #0:2(und): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Time Code
      timecode        : 00:00:00:00
  Stream #0:3(und): Data: bin_data (text / 0x74786574), 0 kb/s
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Text
[16:15:38] Found ffmpeg 9 chapters, container=mov,mp4,m4a,3gp,3g2,mj2
[16:15:38] Added chapter 1, name='Chapter 1', dur=5942186, (00:01:06)
[16:15:38] Added chapter 2, name='Chapter 2', dur=6820564, (00:01:16)
[16:15:38] Added chapter 3, name='Chapter 3', dur=8423415, (00:01:34)
[16:15:38] Added chapter 4, name='Chapter 4', dur=8141883, (00:01:30)
[16:15:38] Added chapter 5, name='Chapter 5', dur=25679404, (00:04:45)
[16:15:38] Added chapter 6, name='Chapter 6', dur=16013498, (00:02:58)
[16:15:38] Added chapter 7, name='Chapter 7', dur=29988708, (00:05:33)
[16:15:38] Added chapter 8, name='Chapter 8', dur=22894122, (00:04:14)
[16:15:38] Added chapter 9, name='Chapter 9', dur=22522, (00:00:00)
[16:15:38] scan: decoding previews for title 1
[16:15:38] scan: preview 1
[16:15:38] fifo_close: trashing 0 buffer(s)
[16:15:38] scan: audio 0x0: pcm_s24le, rate=48000Hz, bitrate=2304000 Unknown (pcm_s24le) (2.0 ch) (2304 kbps)
[16:15:40] scan: preview 2
[16:15:40] scan: preview 3
[16:15:40] scan: preview 4
[16:15:41] scan: preview 5
[16:15:41] scan: preview 6
[16:15:41] scan: preview 7
[16:15:42] scan: preview 8
[16:15:42] scan: preview 9
[16:15:42] scan: preview 10
[16:15:43] scan: 10 previews, 3840x2160, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1, color profile: 9-16-9, chroma location: unspecified
[16:15:43] scan: mastering display metadata: r(0.7080,0.2920) g(0.1700,0.7970) b(0.1310 0.0460) wp(0.3127, 0.3290) min_luminance=0.000100, max_luminance=1000.000000
[16:15:43] scan: content light level: max_cll=1000, max_fall=800
[16:15:43] Freed 1 buffers of size 1024
[16:15:43] Freed 1 buffers of size 4096
[16:15:43] Freed 1 buffers of size 8192
[16:15:43] Freed 1 buffers of size 4194304
[16:15:43] Freed 2 buffers of size 16777216
[16:15:43] Allocated 37762048 bytes of buffers on this pass and Freed 37762048 bytes, 0 bytes leaked
[16:15:43] thread 16d42f000 exited ("scan")
[16:15:43] thread 16d42f000 joined ("scan")
[16:15:43] libhb: scan thread found 1 valid title(s)
[16:15:43] macgui: ScanCore scan done
[16:15:43] thread 16d42f000 started ("yadif_filter_segment")
[16:15:43] thread 16d5d3000 started ("yadif_filter_segment")
[16:15:43] thread 16d777000 started ("yadif_filter_segment")
[16:15:43] thread 16d803000 started ("yadif_filter_segment")
[16:15:43] thread 16d88f000 started ("yadif_filter_segment")
[16:15:43] thread 16d9a7000 started ("yadif_filter_segment")
[16:15:43] thread 16dabf000 started ("yadif_filter_segment")
[16:15:43] thread 16db4b000 started ("yadif_filter_segment")
[16:15:43] thread 16dbd7000 started ("yadif_filter_segment")
[16:15:43] thread 16dc63000 started ("yadif_filter_segment")
[16:15:43] thread 16dcef000 started ("yadif_filter_segment")
[16:15:43] thread 16dd7b000 started ("yadif_filter_segment")
[16:15:43] thread 16de07000 started ("yadif_filter_segment")
[16:15:43] thread 16de93000 started ("yadif_filter_segment")
[16:15:43] thread 16df1f000 started ("yadif_filter_segment")
[16:15:43] thread 16dfab000 started ("yadif_filter_segment")
[16:15:43] thread 16e037000 started ("yadif_filter_segment")
[16:15:43] thread 16e0c3000 started ("yadif_filter_segment")
[16:15:43] thread 16e14f000 started ("yadif_filter_segment")
[16:15:43] thread 16e1db000 started ("yadif_filter_segment")
[16:15:43] decomb: deinterlaced 1 | blended 0 | unfiltered 0 | total 1
[16:15:43] thread 16e0c3000 exited ("yadif_filter_segment")
[16:15:43] thread 16df1f000 exited ("yadif_filter_segment")
[16:15:43] thread 16d42f000 exited ("yadif_filter_segment")
[16:15:43] thread 16dc63000 exited ("yadif_filter_segment")
[16:15:43] thread 16dbd7000 exited ("yadif_filter_segment")
[16:15:43] thread 16e1db000 exited ("yadif_filter_segment")
[16:15:43] thread 16d803000 exited ("yadif_filter_segment")
[16:15:43] thread 16d42f000 joined ("yadif_filter_segment")
[16:15:43] thread 16d88f000 exited ("yadif_filter_segment")
[16:15:43] thread 16db4b000 exited ("yadif_filter_segment")
[16:15:43] thread 16dd7b000 exited ("yadif_filter_segment")
[16:15:43] thread 16de93000 exited ("yadif_filter_segment")
[16:15:43] thread 16dabf000 exited ("yadif_filter_segment")
[16:15:43] thread 16d5d3000 exited ("yadif_filter_segment")
[16:15:43] thread 16e037000 exited ("yadif_filter_segment")
[16:15:43] thread 16dcef000 exited ("yadif_filter_segment")
[16:15:43] thread 16d5d3000 joined ("yadif_filter_segment")
[16:15:43] thread 16de07000 exited ("yadif_filter_segment")
[16:15:43] thread 16d9a7000 exited ("yadif_filter_segment")
[16:15:43] thread 16d777000 exited ("yadif_filter_segment")
[16:15:43] thread 16dfab000 exited ("yadif_filter_segment")
[16:15:43] thread 16d777000 joined ("yadif_filter_segment")
[16:15:43] thread 16e14f000 exited ("yadif_filter_segment")
[16:15:43] thread 16d803000 joined ("yadif_filter_segment")
[16:15:43] thread 16d88f000 joined ("yadif_filter_segment")
[16:15:43] thread 16d9a7000 joined ("yadif_filter_segment")
[16:15:43] thread 16dabf000 joined ("yadif_filter_segment")
[16:15:43] thread 16db4b000 joined ("yadif_filter_segment")
[16:15:43] thread 16dbd7000 joined ("yadif_filter_segment")
[16:15:43] thread 16dc63000 joined ("yadif_filter_segment")
[16:15:43] thread 16dcef000 joined ("yadif_filter_segment")
[16:15:43] thread 16dd7b000 joined ("yadif_filter_segment")
[16:15:43] thread 16de07000 joined ("yadif_filter_segment")
[16:15:43] thread 16de93000 joined ("yadif_filter_segment")
[16:15:43] thread 16df1f000 joined ("yadif_filter_segment")
[16:15:43] thread 16dfab000 joined ("yadif_filter_segment")
[16:15:43] thread 16e037000 joined ("yadif_filter_segment")
[16:15:43] thread 16e0c3000 joined ("yadif_filter_segment")
[16:15:43] thread 16e14f000 joined ("yadif_filter_segment")
[16:15:43] thread 16e1db000 joined ("yadif_filter_segment")
[16:15:43] fifo_close: trashing 0 buffer(s)
[16:15:43] fifo_close: trashing 0 buffer(s)
[16:15:43] fifo_close: trashing 1 buffer(s)
[16:16:12] fifo_close: trashing 0 buffer(s)
[16:16:12] fifo_close: trashing 1 buffer(s)
[16:16:44] Compile-time hardening features are enabled
[16:16:44] hb_init: starting libhb thread
[16:16:44] thread 16f7bf000 started ("libhb")
[16:16:44] macgui: fr.handbrake.HandBrakeXPCService scanning specifically for title: 1
[16:16:44] CPU: 
[16:16:44]  - logical processor count: 20
[16:16:44] hb_scan: path=(hidden for privacy), title_index=1
[16:16:44] thread 16f84b000 started ("scan")
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:333: failed opening UDF image (hidden for privacy)
disc.c:437: error opening file BDMV/index.bdmv
disc.c:437: error opening file BDMV/BACKUP/index.bdmv
bluray.c:2646: nav_get_title_list((hidden for privacy)) failed
[16:16:44] bd: not a bd - trying as a stream/file instead
libdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[16:16:44] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '(hidden for privacy)':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2022-07-12T22:27:07.000000Z
    com.apple.quicktime.keywords: (hidden for privacy)
    com.apple.quicktime.description: (hidden for privacy)
    com.apple.quicktime.author: (hidden for privacy)
    com.apple.quicktime.displayname: (hidden for privacy)
    com.apple.quicktime.title: (hidden for privacy)
  Duration: 00:22:56.96, start: 0.000000, bitrate: 654025 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 66.024292
      Metadata:
        title           : Chapter 1
    Chapter #0:1: start 66.024292, end 141.808333
      Metadata:
        title           : Chapter 2
    Chapter #0:2: start 141.808333, end 235.401833
      Metadata:
        title           : Chapter 3
    Chapter #0:3: start 235.401833, end 325.867208
      Metadata:
        title           : Chapter 4
    Chapter #0:4: start 325.867208, end 611.193917
      Metadata:
        title           : Chapter 5
    Chapter #0:5: start 611.193917, end 789.121667
      Metadata:
        title           : Chapter 6
    Chapter #0:6: start 789.121667, end 1122.329542
      Metadata:
        title           : Chapter 7
    Chapter #0:7: start 1122.329542, end 1376.708667
      Metadata:
        title           : Chapter 8
    Chapter #0:8: start 1376.708667, end 1376.958917
      Metadata:
        title           : Chapter 9
  Stream #0:0(und): Audio: pcm_s24le (lpcm / 0x6D63706C), 48000 Hz, 2 channels, s32 (24 bit), 2304 kb/s (default)
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Video: prores (HQ) (apch / 0x68637061), yuv422p10le(tv, bt2020nc/bt2020/smpte2084, progressive), 3840x2160, 651315 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn, 24k tbc (default)
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : Apple ProRes 422 HQ
      timecode        : 00:00:00:00
    Side data:
      Mastering Display Metadata, has_primaries:1 has_luminance:1 r(0.7080,0.2920) g(0.1700,0.7970) b(0.1310 0.0460) wp(0.3127, 0.3290) min_luminance=0.000100, max_luminance=1000.000000
      Content Light Level Metadata, MaxCLL=1000, MaxFALL=800
  Stream #0:2(und): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Time Code
      timecode        : 00:00:00:00
  Stream #0:3(und): Data: bin_data (text / 0x74786574), 0 kb/s
    Metadata:
      creation_time   : 2022-07-12T22:27:07.000000Z
      handler_name    : Core Media Text
[16:16:44] Found ffmpeg 9 chapters, container=mov,mp4,m4a,3gp,3g2,mj2
[16:16:44] Added chapter 1, name='Chapter 1', dur=5942186, (00:01:06)
[16:16:44] Added chapter 2, name='Chapter 2', dur=6820564, (00:01:16)
[16:16:44] Added chapter 3, name='Chapter 3', dur=8423415, (00:01:34)
[16:16:44] Added chapter 4, name='Chapter 4', dur=8141883, (00:01:30)
[16:16:44] Added chapter 5, name='Chapter 5', dur=25679404, (00:04:45)
[16:16:44] Added chapter 6, name='Chapter 6', dur=16013498, (00:02:58)
[16:16:44] Added chapter 7, name='Chapter 7', dur=29988708, (00:05:33)
[16:16:44] Added chapter 8, name='Chapter 8', dur=22894122, (00:04:14)
[16:16:44] Added chapter 9, name='Chapter 9', dur=22522, (00:00:00)
[16:16:44] scan: decoding previews for title 1
[16:16:44] scan: preview 1
[16:16:44] fifo_close: trashing 0 buffer(s)
[16:16:44] scan: audio 0x0: pcm_s24le, rate=48000Hz, bitrate=2304000 Unknown (pcm_s24le) (2.0 ch) (2304 kbps)
[16:16:46] scan: preview 2
[16:16:46] scan: preview 3
[16:16:46] scan: preview 4
[16:16:47] scan: preview 5
[16:16:47] scan: preview 6
[16:16:47] scan: preview 7
[16:16:48] scan: preview 8
[16:16:48] scan: preview 9
[16:16:48] scan: preview 10
[16:16:48] scan: 10 previews, 3840x2160, 23.976 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1, color profile: 9-16-9, chroma location: unspecified
[16:16:48] scan: mastering display metadata: r(0.7080,0.2920) g(0.1700,0.7970) b(0.1310 0.0460) wp(0.3127, 0.3290) min_luminance=0.000100, max_luminance=1000.000000
[16:16:48] scan: content light level: max_cll=1000, max_fall=800
[16:16:48] Freed 1 buffers of size 1024
[16:16:48] Freed 1 buffers of size 4096
[16:16:48] Freed 1 buffers of size 8192
[16:16:48] Freed 1 buffers of size 4194304
[16:16:48] Freed 2 buffers of size 16777216
[16:16:48] Allocated 37762048 bytes of buffers on this pass and Freed 37762048 bytes, 0 bytes leaked
[16:16:48] thread 16f84b000 exited ("scan")
[16:16:48] thread 16f84b000 joined ("scan")
[16:16:48] libhb: scan thread found 1 valid title(s)
[16:16:49] macgui: fr.handbrake.HandBrakeXPCService scan done
[16:16:49] thread 16f84b000 started ("work")
[16:16:49] macgui: fr.handbrake.HandBrakeXPCService started encoding Stewie_first_days_HDR.mkv
[16:16:49] macgui: fr.handbrake.HandBrakeXPCService with preset 4K Blu-ray HDR x265 25 Mbps (Modified)
[16:16:49] Starting work at: Wed Jul 13 16:16:49 2022

[16:16:49] 1 job(s) to process
[16:16:49] Starting Task: Encoding Pass
[16:16:49] Skipping crop/scale filter
[16:16:49] job configuration:
[16:16:49]  * source
[16:16:49]    + /Users/sebastianalvarez/Video Editing/Renders/Stewie_first_days_HDR.mov
[16:16:49]    + title 1, chapter(s) 1 to 9
[16:16:49]    + container: mov,mp4,m4a,3gp,3g2,mj2
[16:16:49]    + data rate: 654025 kbps
[16:16:49]  * destination
[16:16:49]    + /Users/sebastianalvarez/To burn/Stewie_first_days_HDR.mkv
[16:16:49]    + container: Matroska (libavformat)
[16:16:49]      + chapter markers
[16:16:49]  * video track
[16:16:49]    + decoder: prores 10-bit (yuv420p10le)
[16:16:49]      + bitrate 651315 kbps
[16:16:49]    + filters
[16:16:49]      + Framerate Shaper (mode=1:rate=27000000/1126125)
[16:16:49]        + frame rate: 23.976 fps -> constant 23.976 fps
[16:16:49]      + AVFilter (zscale='transfer=linear:npl=100',format='pix_fmts=gbrpf32le',tonemap='tonemap=hable:desat=0:peak=10',zscale='transfer=2020_10',format='pix_fmts=yuv420p10le')
[16:16:49]        + zscale: transfer=linear, npl=100
[16:16:49]        + format: pix_fmts=gbrpf32le
[16:16:49]        + tonemap: tonemap=hable, desat=0, peak=10
[16:16:49]        + zscale: transfer=2020_10
[16:16:49]        + format: pix_fmts=yuv420p10le
[16:16:49]      + Colorspace (primaries=bt2020:transfer=bt2020-10:matrix=bt2020ncl:tonemap=hable:desat=0)
[16:16:49]    + Output geometry
[16:16:49]      + storage dimensions: 3840 x 2160
[16:16:49]      + pixel aspect ratio: 1 : 1
[16:16:49]      + display dimensions: 3840 x 2160
[16:16:49]    + encoder: H.265 10-bit (libx265)
[16:16:49]      + preset:  veryfast
[16:16:49]      + options: uhd-bd=1:hdr=1:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc
[16:16:49]      + profile: auto
[16:16:49]      + level:   auto
[16:16:49]      + bitrate: 25000 kbps, pass: 0
[16:16:49]      + color profile: 9-14-9
[16:16:49]      + chroma location: unspecified
[16:16:49]  * audio track 1
[16:16:49]    + decoder: Unknown (pcm_s24le) (2.0 ch) (2304 kbps) (track 1, id 0x0)
[16:16:49]      + bitrate: 2304 kbps, samplerate: 48000 Hz
[16:16:49]    + mixdown: Stereo
[16:16:49]    + encoder: AC3 (libavcodec)
[16:16:49]      + bitrate: 448 kbps, samplerate: 48000 Hz
[16:16:49] sync: expecting 33013 video frames
[16:16:49] thread 1709cb000 started ("Audio Synchronization")
x265 [info]: HEVC encoder version 3.5+1-f0c1022b6
x265 [info]: build info [Mac OS X][clang 13.0.0][32 bit] 10bit
x265 [info]: using cpu capabilities: NEON
x265 [warning]: uhd-bd: Turning on repeat-headers
x265 [warning]: uhd-bd: Turning off open GOP
x265 [warning]: uhd-bd: keyframeMin is always 1
x265 [warning]: uhd-bd: reducing keyframeMax to 24
x265 [info]: Main 10 profile, Level-5.1 (High tier)
x265 [info]: Thread pool created using 20 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 4 / wpp(34 rows)
x265 [warning]: NAL HRD parameters require VBV parameters, ignored
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 1 / 2
x265 [info]: Keyframe min / max / scenecut / bias  : 1 / 24 / 40 / 5.00 
x265 [info]: Lookahead / bframes / badapt        : 15 / 4 / 0
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 2 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : ABR-25000 kbps / 0.60
x265 [info]: tools: rd=2 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: fast-intra strong-intra-smoothing lslices=8 deblock sao
[16:16:49] Writing Metadata to output file...
[16:16:49] thread 171777000 started ("Muxer")
[16:16:49] thread 171803000 started ("Reader")
[16:16:49] thread 17188f000 started ("Audio decoder (libavcodec)")
[16:16:49] thread 17191b000 started ("Video decoder (libavcodec)")
[16:16:49] thread 1719a7000 started ("Video Synchronization")
[16:16:49] thread 171a33000 started ("AVCodec Audio encoder (libavcodec)")
[16:16:49] thread 171abf000 started ("H.265/HEVC encoder (libx265)")
[16:16:49] thread 171b4b000 started ("Muxer")
[16:16:49] thread 171bd7000 started ("Framerate Shaper")
[16:16:49] thread 171c63000 started ("AVFilter")
[16:16:49] ffmpeg_read starting chapter 1 at 0
[16:16:51] sync: first pts video is 0
[16:16:51] sync: "Chapter 1" (1) at frame 1 time 0
[16:16:51] sync: first pts audio 0x0 is 0

(this is just the first 5 or so seconds of encoding, I figured all the important info was here anyway)

Anyway, I would really appreciate your help on this.
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

Well, that didn't work either. I thought, maybe it doesn't supposed to have colons, maybe it's spaces, so I tried:

uhd-bd=1 hdr=1 hdr-opt=1 repeat-headers=1 colorprim=bt2020 transfer=smpte2084 colormatrix=bt2020nc

But the log showed:

[17:09:42] encx265: bad argument 'uhd-bd=1 hdr=1 hdr-opt=1 repeat-headers=1 colorprim=bt2020 transfer=smpte2084 colormatrix=bt2020nc'

So I stopped it right away. Any suggestions?
Deleted User 11865

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by Deleted User 11865 »

sebastianthenerd wrote: Wed Jul 13, 2022 9:11 pm Well, that didn't work either.
Can you please elaborate, how did it not work?
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

Oh, sorry, I thought it was clear from the line in the log that I pasted:

[17:09:42] encx265: bad argument 'uhd-bd=1 hdr=1 hdr-opt=1 repeat-headers=1 colorprim=bt2020 transfer=smpte2084 colormatrix=bt2020nc'

So, it says that it's a bad argument, so I take it that it's not the correct syntax for multiple parameters. So right now I'm trying one with just hdr=1 because it seems to work for the first parameter, like when I entered "uhd-bd=1:hdr=1:hdr-opt=1:repeat- headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" I know it recognized the uhd-bd=1 because I saw this:

Code: Select all

x265 [warning]: uhd-bd: Turning on repeat-headers
x265 [warning]: uhd-bd: Turning off open GOP
x265 [warning]: uhd-bd: keyframeMin is always 1
x265 [warning]: uhd-bd: reducing keyframeMax to 24
But I didn't see any of the other parameters I entered there. So what's the correct separator for multiple parameters? Comma? Colon? Semicolon? Other?
Deleted User 11865

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by Deleted User 11865 »

Most libx265 options will be silently applied if the option and argument are both valid. uhd-bd is the exception, rather than the rule.
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

Rodeo wrote: Wed Jul 13, 2022 9:48 pm Most libx265 options will be silently applied if the option and argument are both valid. uhd-bd is the exception, rather than the rule.
Sorry, what's "silently applied"? Basically what I would like to know is what would be the correct way to enter all these additional parameters into Handbrake:

uhd-bd=1 hdr=1 hdr-opt=1 repeat-headers=1 colorprim=bt2020 transfer=smpte2084 colormatrix=bt2020nc
mduell
Veteran User
Posts: 8198
Joined: Sat Apr 21, 2007 8:54 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by mduell »

You had it right with the colons. Most of the options don't produce debug output when they are done correctly.
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

mduell wrote: Thu Jul 14, 2022 1:35 am You had it right with the colons. Most of the options don't produce debug output when they are done correctly.
OK, good. However, the question for me remains, is Handbrake capable of encoding HDR content from a Prores 422 HQ or even a 4444 that has been exported with the proper HDR flags, in either VideoToolbox or x265? Because I did a few encodes in the last few hours, one of them with only the HDR flag, and even that didn't produce an HDR file.

Then I did one with x265 with these options: hdr=1:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc and that didn't work.

Then I did one with VideoToolbox with almost the same options: hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:max-cll=1000,800:uhd-bd=1

That didn't work either. So at this point I'm not sure what other tests I can run. And it's not a really big deal because I don't exactly need HDR for the footage of my puppy shot on my iPhone 11 Pro Max and Canon XF100 in 1080p, and at least Handbrake allows me to make a file that BD Rebuilder at one point used to take without issues and without recompressing, and then magically stopped for no reason, but at least there's hope.

But, if I could encode that footage to HDR, I would prefer that, as long as I don't have to do 10,000 different things with a lot CLI programs and all that, but based on what I had read, I thought that Handbrake was able to encode to HDR, but maybe that's only in the Windows version?
User avatar
Ritsuka
HandBrake Team
Posts: 1655
Joined: Fri Jan 12, 2007 11:29 am

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by Ritsuka »

You don't need to all those additional options, everything is already set, you only need uhd-bd if you want to use it for a bluray (which I never tested, and which VideoToolbox doesn't support: https://handbrake.fr/docs/en/1.5.0/tech ... olbox.html ).

The issue is that you enabled the colourspace filter, and set it to convert to a non HDR colourspace. Disable it.
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

Ritsuka wrote: Thu Jul 14, 2022 8:31 am You don't need to all those additional options, everything is already set, you only need uhd-bd if you want to use it for a bluray (which I never tested, and which VideoToolbox doesn't support: https://handbrake.fr/docs/en/1.5.0/tech ... olbox.html ).

The issue is that you enabled the colourspace filter, and set it to convert to a non HDR colourspace. Disable it.
Sorry, if I edited in FCPX in a Rec.2020 project and the exported file is Rec.2020, shouldn't that be enabled?

Also, in the test I left running before going to sleep last night, this time I encoded to an m4v instead of mkv, which means that Quicktime Player can open it. And that file still shows no HDR in media info, however in the info panel in QT player is does show it's HDR, but it looks really dark and with excessive colors on the regular monitor, which is not the case for the Prores file, which is also HDR. So I don't know why that is, but I'll burn it to a BD-RE later and see what it looks like on the TV set.
User avatar
Ritsuka
HandBrake Team
Posts: 1655
Joined: Fri Jan 12, 2007 11:29 am

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by Ritsuka »

No, the "Bt.2020" option in the colourspace filter means Bt.2020 transfer function. Final Cut probably means Rec.2020 color primaries. HDR uses a different transfer function that is defined in Rec.2100.
The colourspace filter is used to convert from one colourspace to another, in your case you want to keep the source one, so there is no need to enable it.
sebastianthenerd
Posts: 7
Joined: Wed Jul 13, 2022 7:42 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by sebastianthenerd »

Well, you know your stuff well, because after setting that to off, I finally got the first file out of Handbrake that gives me an HDR file that both Quicktime Player and Mediainfo recognized as such. The additional options I used are:

hdr=1:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:max-cll=1000,800:uhd-bd=1

Here's the Mediainfo output:

Code: Select all

General
Complete name                            : /(path hidden for privacy)/Stewie_first_days_HDR_Test_05.m4v
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/iso2/mp41)
File size                                : 3.84 GiB
Duration                                 : 22 min 56 s
Overall bit rate                         : 24.0 Mb/s
Encoded date                             : UTC 2022-07-14 14:31:11
Tagged date                              : UTC 2022-07-14 14:31:11
Writing application                      : HandBrake 1.5.1 2022011000

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5.1@High
HDR format                               : SMPTE ST 2086, HDR10 compatible
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 22 min 56 s
Bit rate                                 : 23.5 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 23.976 (24000/1001) FPS
Minimum frame rate                       : 23.974 FPS
Maximum frame rate                       : 23.981 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0 (Type 2)
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.118
Stream size                              : 3.77 GiB (98%)
Writing library                          : x265 3.5+1-f0c1022b6:[Mac OS X][clang 13.0.0][32 bit] 10bit
Encoding settings                        : cpuid=2 / frame-threads=4 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x2160 / interlace=0 / total-frames=0 / level-idc=51 / high-tier=1 / uhd-bd=1 / ref=3 / no-allow-non-conformance / repeat-headers / annexb / aud / no-hrd / info / hash=0 / no-temporal-layers / no-open-gop / min-keyint=1 / keyint=24 / gop-lookahead=0 / bframes=4 / b-adapt=0 / b-pyramid / bframe-bias=0 / rc-lookahead=15 / lookahead-slices=8 / scenecut=40 / hist-scenecut=0 / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=2 / limit-refs=3 / no-limit-modes / me=1 / subme=2 / 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=2 / selective-sao=4 / no-early-skip / rskip / fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=abr / bitrate=25000 / 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=0 / colorprim=9 / transfer=16 / colormatrix=9 / chromaloc=1 / chromaloc-top=2 / chromaloc-bottom=2 / display-window=0 / master-display=G(8500,39850)B(6550,2300)R(35400,14600)WP(15635,16450)L(10000000,1) / cll=1000,800 / min-luma=0 / max-luma=1023 / 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 / hist-threshold=0.03 / no-opt-cu-delta-qp / no-aq-motion / hdr10 / 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
Encoded date                             : UTC 2022-07-14 14:31:11
Tagged date                              : UTC 2022-07-14 14:31:11
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant
Mastering display color primaries        : BT.2020
Mastering display luminance              : min: 0.0001 cd/m2, max: 1000 cd/m2
Maximum Content Light Level              : 1000 cd/m2
Maximum Frame-Average Light Level        : 800 cd/m2
Menus                                    : 3
mdhd_Duration                            : 1376959
Codec configuration box                  : hvcC

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : ac-3
Duration                                 : 22 min 56 s
Source duration                          : 22 min 56 s
Bit rate mode                            : Constant
Bit rate                                 : 448 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Compression mode                         : Lossy
Stream size                              : 73.5 MiB (2%)
Source stream size                       : 73.5 MiB (2%)
Title                                    : Stereo
Service kind                             : Complete Main
Default                                  : Yes
Alternate group                          : 1
Encoded date                             : UTC 2022-07-14 14:31:11
Tagged date                              : UTC 2022-07-14 14:31:11
Menus                                    : 3
mdhd_Duration                            : 1376923

Menu
ID                                       : 3
Format                                   : Timed Text
Codec ID                                 : text
Duration                                 : 22 min 56 s
Language                                 : English
Encoded date                             : UTC 2022-07-14 14:31:11
Tagged date                              : UTC 2022-07-14 14:31:11
Bit rate mode                            : CBR
Menu For                                 : 1,2
00:00:00.000                             : Chapter 1
00:01:06.024                             : Chapter 2
00:02:21.808                             : Chapter 3
00:03:55.402                             : Chapter 4
00:05:25.867                             : Chapter 5
00:10:11.194                             : Chapter 6
00:13:09.122                             : Chapter 7
00:18:42.330                             : Chapter 8
Bit rate mode                            : Constant

So thanks so much for your information. Now, the next mission is to get BD Rebuilder to author without re-encoding.

Also, might be good to put this thread as a sticky, or even just create a simple post for other people that are trying to achieve the same thing. It took me a couple of weeks to finally get the right information on this, and if it was in the documentation or a post at the top, it would really useful to many people.
User avatar
Ritsuka
HandBrake Team
Posts: 1655
Joined: Fri Jan 12, 2007 11:29 am

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by Ritsuka »

Additional options can be simplified:
colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:max-cll=1000,800 are not needed, they are read from your source file.
hdr=1:hdr-opt=1 are not needed either, these options are enabled automatically if the source is HDR.
mduell
Veteran User
Posts: 8198
Joined: Sat Apr 21, 2007 8:54 pm

Re: Can Handbrake encode HDR HEVC for 4k Blu-ray?

Post by mduell »

sebastianthenerd wrote: Thu Jul 14, 2022 4:06 pmAlso, might be good to put this thread as a sticky, or even just create a simple post for other people that are trying to achieve the same thing. It took me a couple of weeks to finally get the right information on this, and if it was in the documentation or a post at the top, it would really useful to many people.
Nothing personal, but there's easily a dozen topics of more general interest that aren't stickied that are far less niche than encoding for 4K HDR Blu-ray.
Post Reply