Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
2nd April 2017, 12:26 | #1 | Link |
Registered User
Join Date: Feb 2003
Location: Palmcoast of Norway
Posts: 363
|
tuning x265 syntax for UHD /rec2020,HDR10/high quality
hi! Im working on encoding some clips i have in pro-res format to HEVC for HDR10 testing.
Source: Prores 4:2:2 10bit UHD - Nature scene 10000frames Syntax: Pass 1: ffmpeg -i "output2.mov" -strict -1 -vf scale=out_color_matrix=bt2020ncut_h_chr_pos=0ut_v_chr_pos=0,format=yuv420p10 -an -r 25 -f yuv4mpegpipe - | "x265.exe" --y4m - --output-depth 10 --input-res 3840x2160 --fps 25 --preset veryslow --b-adapt 2 --ref 4 --open-gop --keyint 48 --profile main10 --level-idc 5.1 --no-high-tier --sar 1:1 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --b-pyramid --bframes 4 --hrd --vbv-bufsize 35000 --bitrate 35000 --vbv-maxrate 40000 --slow-firstpass --pass 1 --stats "test_HDR10.stats" --aud --chromaloc 2 --max-cll "1000,400" --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,0.0050)" --output nul Pass 2: ffmpeg -i "output2.mov" -strict -1 -vf scale=out_color_matrix=bt2020ncut_h_chr_pos=0ut_v_chr_pos=0,format=yuv420p10 -an -r 25 -f yuv4mpegpipe - | "x265.exe" --y4m - --output-depth 10 --input-res 3840x2160 --fps 25 --preset slow --b-adapt 2 --ref 4 --open-gop --keyint 48 --profile main10 --level-idc 5.1 --no-high-tier --sar 1:1 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --b-pyramid --bframes 4 --hrd --vbv-bufsize 35000 --bitrate 35000 --vbv-maxrate 40000 --slow-firstpass --pass 2 --stats "test_HDR10.stats" --aud --chromaloc 2 --max-cll "1000,400" --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,0.0050)" --output "test_HDR10.hevc" Ive selected slow on the 2nd pass since it takes like 3 days to encode on my Haswell if not.. In the recent 2.3 release of x265, there are some new features for HDR.. Not sure how to incorporate the hdr features.. any comments are welcomed TEB |
2nd April 2017, 13:33 | #2 | Link |
Testeur de codecs
Join Date: May 2003
Location: France
Posts: 2,484
|
seem good for HDR profil.
Anyway you use something like "UHD BD" profil (HDR, VBV, GOP, profil ...). If you want make that, use --uhd-bd command line.
__________________
Le Sagittaire ... ;-) 1- Ateme AVC or x264 2- VP7 or RV10 only for anime 3- XviD, DivX or WMV9 |
5th April 2017, 17:45 | #3 | Link |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
|
How about --hdr-opt?
And --b-pyramid is always on by default. are you looking for the x265 equivalent to --b-pyramid strict? Because there isn't one. I don't know if that's a requirement for UHD BD or not. Which IIRC had something to do why UHD-BD encoding required closed GOP or something. |
5th April 2017, 23:15 | #4 | Link |
Registered User
Join Date: Apr 2016
Posts: 19
|
I use madvr to watch HDR videos, the problem is that in encodes I do I get red or blue colors or boxes in video, tried so many encoding settings, spent days, but no good solution so far, tried slower settings, with grain, film (suggest in forum), than many settings tested from me, different rdoq level, different aq mode, deblock, sao/no-sao etc..
|
6th April 2017, 20:42 | #5 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
|
Quote:
You might try --cbqpoffs -3 --crqpoffs -3 to see if lowering QP for chroma improves things. And definitely --hdr-opt. But what you describe could be a MadVR playback issue that isn't related to encoding. |
|
6th April 2017, 23:05 | #6 | Link | |
Registered User
Join Date: Apr 2016
Posts: 19
|
Quote:
|
|
6th April 2017, 23:40 | #7 | Link | |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
|
Quote:
|
|
7th April 2017, 04:59 | #8 | Link | |
Registered User
Join Date: Apr 2016
Posts: 19
|
Quote:
I'm encoding with low bitrate and maybe this is a reason too, I did set the HDR settings right, based in mediainfo, so primaries, matrix, characteristics, matrix, light level, chroma, master display are all right. I used so many encoding settings used, from slow/slower/veryslow, grain, no tune or the film tune recommended in this forum. Here I explain what I tried: deblock 0, -1, -2 (less = more details) rdoq 0, 1, 4, 5, 8, 10 (not big difference) psy-rd 0.3, 1.5, 1.8, 2 (mostly 2 for less blur) qcomp 0.6, 0.7, 0.8 (0.8 worked better) cutree on/off (off worked better) opt-cu-delta-qp on/off (prefered on) rskip on/off (only reducing speed for nothing) aq-mode 1, 2, 3 (2 always fully disabled the hdr -the x265 staff should fix it, 3 worked ok) ipratio bpratio 1.1-1.0, 1.4-1.3 mostly but also others. (less for more details) rect, no-amp (amp = no difference, sometimes it also crashed the encoding process) b-frames 4-6 no-fast-tskip sao or no-sao rd-penalty 0, 1, 2 (1 and 2 increased the details of video but changed the lights) the rest settings were general preset settings. I did made around 50 test encodes, it was a 500 frame video so I had no problem to spend 10 minutes to encode, but it didn't fix the problem on how I wanted, during the tests I saw from the worst blured encodes to almost no details lost but my problem are the colors. It is a Madvr problem or HDR is just complex? In every encode something changed, even the smallers options changed something. There are red or blue colors appearing likes boxes, pixels etc. Sometimes more, sometimes less, in every encode is different, sometimes there is more red, and it's not in the same part of the frame, it can happen in different. I have an i7 and the source plays well, while the encode has those problems. Don't know if it is a normal thing. Screens: 1. Colors more white. http://screenshotcomparison.com/comparison/205881 2. Red things (the second pic is source), this doesn't show everything, as it's not that the red appears only in complex parts like this. http://screenshotcomparison.com/comparison/205882 3. Blue: http://screenshotcomparison.com/comparison/205883 Last edited by albt; 7th April 2017 at 05:04. |
|
7th April 2017, 20:28 | #9 | Link |
Moderator
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
|
For a simple baseline, try trimming the x265.exe part to:
x265.exe" --y4m - --preset slower --hdr-opt --keyint 48 --profile main10 --level-idc 5.0 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --hrd --vbv-bufsize 25000 --bitrate 25000 --vbv-maxrate 25000 --slow-firstpass --pass 2 --stats "test_HDR10.stats" --aud --chromaloc 2 --max-cll "1000,400" --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,0.0050)" --output "test_HDR10.hevc I took out the stuff inherited from y4m and the preset. I bumped it up to slower, which is where most of the HEVC features kick in, and added --hdr-opt, which fixes the sort of chroma issues it seems you're getting. Although I'm surprised that you'd be getting any issues like that at 35 Mbps! The whole --chromaloc 2 thing is a little suspect for me in general. It's required by UHD-BD, but I don't know that sources are ever converted to that, nor if decoders/displays correct for that in their YUV-RGB conversion. So you might removing ut_h_chr_pos etcetera from ffmpeg and remove chromaloc 2 from x265. |
7th April 2017, 21:00 | #10 | Link | |
Registered User
Join Date: Apr 2016
Posts: 19
|
Quote:
--chromaloc 2 --colorprim bt2020 --transfer smpte-st-2084 --colormatrix bt2020nc --max-cll "1000,400" --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,50)" i'll test your suggestions. |
|
7th July 2017, 08:22 | #12 | Link | ||
Registered User
Join Date: Jun 2017
Posts: 89
|
Quote:
The docs say this: Quote:
What luma and chroma offsets? Will the result be visually inferior? I encoded the "Samsung HDR Wonderland" demo, once with --hdr-opt and once without. Source MediaInfo: Code:
Video ID : 1 Format : HEVC Format/Info : High Efficiency Video Coding Format profile : Main 10@L5.1@High Codec ID : V_MPEGH/ISO/HEVC Duration : 2 min 41 s Bit rate : 45.7 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:0 Bit depth : 10 bits Bits/(Pixel*Frame) : 0.230 Stream size : 878 MiB (100%) Writing library : ATEME Titan File 3.7.3 (4.7.3.1002) Default : Yes Forced : No Color range : Limited Color primaries : BT.2020 Transfer characteristics : SMPTE ST 2084 Matrix coefficients : BT.2020 non-constant Mastering display color primaries : R: x=0.680000 y=0.320000, G: x=0.265000 y=0.690000, B: x=0.150000 y=0.060000, White point: x=0.312700 y=0.329000 Mastering display luminance : min: 0.0500 cd/m2, max: 1000.0000 cd/m2 CRF17, medium, no tune CL custom: --no-sao --uhd-bd --hdr-opt --hrd --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500)" (I would normally add --max-cll too, but the source does not include that information...) MediaInfo: Code:
Video ID : 1 Format : HEVC Format/Info : High Efficiency Video Coding Format profile : Main 10@L5.1@High Codec ID : V_MPEGH/ISO/HEVC Duration : 2 min 41 s Bit rate : 22.2 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:0 (Type 2) Bit depth : 10 bits Bits/(Pixel*Frame) : 0.112 Stream size : 427 MiB (98%) Writing library : x265 2.4+13-26963e98fa64:[Windows][MSVC 1910][64 bit] 10bit Encoding settings : cpuid=1173503 / frame-threads=2 / numa-pools=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 / hrd / info / hash=0 / no-temporal-layers / no-open-gop / min-keyint=1 / keyint=24 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=8 / scenecut=40 / 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 / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / no-sao / no-sao-non-deblock / rd=3 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=0.00 / no-rd-refine / analysis-mode=0 / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=17.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / vbv-maxrate=160000 / vbv-bufsize=160000 / vbv-init=0.9 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=1 / 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(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,500) / max-cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / opt-qp-pps / opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / no-opt-cu-delta-qp / no-aq-motion / hdr / hdr-opt / no-dhdr10-opt / refine-level=5 / no-limit-sao Default : Yes Forced : No Color range : Limited Color primaries : BT.2020 Transfer characteristics : SMPTE ST 2084 Matrix coefficients : BT.2020 non-constant Mastering display color primaries : R: x=0.680000 y=0.320000, G: x=0.265000 y=0.690000, B: x=0.150000 y=0.060000, White point: x=0.312700 y=0.329000 Mastering display luminance : min: 0.0500 cd/m2, max: 1000.0000 cd/m2 Code:
Bit rate : 25.7 Mb/s Also, would you be so kind as to "sanity check" those parameters? Would you change anything for UHD HDR encoding? Is anything essential missing? I think you also suggested before: --chromaloc 2 --keyint 48 ? I try to read up on the parameters as much as I can, but everything UHD HDR is not really well documented... So I welcome any help and explanations! |
||
11th July 2017, 18:18 | #13 | Link |
Registered User
Join Date: Jun 2017
Posts: 89
|
I just tried to play the encoded files with my TV's internal media player - unfortunately it won't play them.
Kodi plays them fine (S905X LibreELEC, build with enabled 10bit, HDR10 and BT.2020 passtrough). The TV's internal player has no issues playing the source file. Does anyone know the reason? I thought --chromaloc 1 might be the reason so I tried the same encode with --chromaloc 2, but the result is still --chromaloc 1. I tried the same withought --uhd-bd, but it still comes out --chromaloc 1... The only difference between source and encode in the main stats I see is... Code:
Chroma subsampling : 4:2:0 (Type 2) |
11th July 2017, 20:53 | #14 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
Could be different muxing or different audio. Don't shorten MediaInfo logs to just the video track's section. If you demux a working file and mux it in the same way you muxed your not working encode does it play or not?
|
11th July 2017, 21:21 | #15 | Link |
Registered User
Join Date: Jun 2017
Posts: 89
|
I remuxed the original downloaded demo with MKVToolNix 13.0 to just video.
There is no audio or subtitle. I played this remuxed video with the TV's internal player, it plays fine. I don't know why it says 98% for stream size on the encodes... I used HandBrake 1.0.7 for encoding. Only the encodes won't play.... Do the parameters look ok to you? |
11th July 2017, 21:35 | #16 | Link |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
Are you still using HandBrake? Try to demux and mux using MKVToolNix as well. (If only track has 98% size then MediaInfo estimates mkv container overhead to be the remaining 2%.)
Basically, just keep turning knobs until you have something that works. Try x265cli instead of HandBrake. Try lower level, lower resolution. Try without HDR and UHD-BD options etc. |
12th July 2017, 07:12 | #17 | Link | |
Registered User
Join Date: Jun 2017
Posts: 89
|
Source and encode level + resolution are the same...
I am aiming for a transparent encode, lowering the resolution would not really be productive... Quote:
I will try and see if removing --uhd-bd changes things. The whole reason for the --uhd-bd command is to ensure compatibility, isn't it? That confuses me... |
|
12th July 2017, 07:29 | #18 | Link | |
Registered User
Join Date: Dec 2002
Posts: 5,565
|
Yes, the flags. But (vbv) bitrates might be different.
Just test. Once you've found the culprit you can go back and reactivate settings one by one. Quote:
Compliance with UltraHD Blu-ray (and probably not even that). Since you aren't authoring a Blu-ray that doesn't ensure compatibility with your player. (And then there's still muxing as a factor.) |
|
14th July 2017, 08:52 | #20 | Link |
Registered User
Join Date: Jun 2017
Posts: 89
|
Weirdly, the only change that was accepted by the TV's media player was removing the --master-display string (I did however add --hdr instead).
Out of interest, will the encode in that case still use the same master display specs, but just not "announce" them in the container? I see no obvious difference in color, contrast, peak brightness etc... |
Thread Tools | Search this Thread |
Display Modes | |
|
|