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.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 22nd March 2025, 16:07   #1  |  Link
Perenista
Registered User
 
Join Date: Oct 2013
Posts: 229
Handbrake and two methods of reencoding UHD-4K content

The two methods gave me a difference in brightness/contrast.

Note: this is a 1080p reencode from UHD-4K content. So our goal is to create what would be best to watch in 1080p, I guess calling it "SDR version" is the proper term. We will also assume there isn't any official Blu-ray, created by professional colorists, which is obviously going to be better than whatever we do automatically with this app.

What I can't figure out is which is correct, in the end. The answers at least from AI, were conflicting. It hinted that file #2, which I created later and has less brightness/contrast, may be better.

Reencodes using H.265. The #2 one with a higher bitrate, uses BT.709 and 10-bit for HEVC.

Take a look:

ORIGINAL UHD-4K file (MKV, lossless):

https://pastebin.com/VTmh1Cir

NOW, the file with less bitrate, and increased brightness:

https://pastebin.com/Eqzhb5cF

The #2 one:

https://pastebin.com/cPusHwcD

Any ideas?

+++++++
One thing I learned is that if we disable colourspace for a 4K - 1080p reencode, the final result is 8-bit and clearly bad/wrong, with video artifacts.

Another change I made was to set a fixed bitrate for HANDBRAKE, and disabled "anamorphic", as explained here:

https://forum.doom9.org/showthread.php?t=186022
Perenista is offline   Reply With Quote
Old 23rd March 2025, 17:23   #2  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 333
From an encoding point of view, the second one will be better because of its higher bitrate. The BT.709 trifecta are also set properly, though in practice, it shouldn't make a difference at 1080p. The x265 encoding would be further improved by using the slow or slower preset.

Regarding the HDR to SDR conversion, if it is possible, give FFmpeg and libplacebo a go and see if the results are better.

Code:
Collapse all onto a single line, adjusting the crop values, CRF, and other settings as desired:

ffmpeg -init_hw_device vulkan -i INPUT.mkv -map 0:v:0 -vf libplacebo=upscaler=spline36:downscaler=spline36:w=-1:h=1080:
                                                          colorspace=bt709:color_trc=bt709:color_primaries=bt709:range=limited:format=yuv420p10le,
                                                          crop=1920:1080:0:0:exact=true,sidedata=delete

                                                          -c:v libx265 -preset slow -crf 20 -x265-params no-sao=1:deblock=-1,-1:aq-mode=3 OUTPUT.mp4

Last edited by GeoffreyA; 23rd March 2025 at 17:42.
GeoffreyA is offline   Reply With Quote
Old 25th March 2025, 17:43   #3  |  Link
PatchWorKs
Registered User
 
PatchWorKs's Avatar
 
Join Date: Aug 2002
Location: Italy
Posts: 323
Suggestion for @Perenista: switch to FastFlix if you need more controls over encoding parameters...
__________________
Hybrid Multimedia Production Suite will be a platform-indipendent open source suite for advanced audio/video contents production.

Official git: https://forart.it/HyMPS
PatchWorKs is offline   Reply With Quote
Old 26th March 2025, 10:12   #4  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 368
Quote:
Originally Posted by GeoffreyA View Post
From an encoding point of view, the second one will be better because of its higher bitrate. The BT.709 trifecta are also set properly, though in practice, it shouldn't make a difference at 1080p. The x265 encoding would be further improved by using the slow or slower preset.

Regarding the HDR to SDR conversion, if it is possible, give FFmpeg and libplacebo a go and see if the results are better.

Code:
Collapse all onto a single line, adjusting the crop values, CRF, and other settings as desired:

ffmpeg -init_hw_device vulkan -i INPUT.mkv -map 0:v:0 -vf libplacebo=upscaler=spline36:downscaler=spline36:w=-1:h=1080:
                                                          colorspace=bt709:color_trc=bt709:color_primaries=bt709:range=limited:format=yuv420p10le,
                                                          crop=1920:1080:0:0:exact=true,sidedata=delete

                                                          -c:v libx265 -preset slow -crf 20 -x265-params no-sao=1:deblock=-1,-1:aq-mode=3 OUTPUT.mp4
I have not used libplacebo, but im pretty sure TS would like to tonemap from HDR to SDR. Is that done automatically, cause I cannot see that specified in the commandline?
excellentswordfight is offline   Reply With Quote
Old 26th March 2025, 13:52   #5  |  Link
GeoffreyA
Registered User
 
Join Date: Jun 2024
Location: South Africa
Posts: 333
Quote:
Originally Posted by excellentswordfight View Post
I have not used libplacebo, but im pretty sure TS would like to tonemap from HDR to SDR. Is that done automatically, cause I cannot see that specified in the commandline?
It's done automatically, depending on the source and destination. BT.709 matrix, transfer, and primaries were set for the output, so, if the source is HDR, it will perform conversion, tone mapping, etc. For my part, I use the following, more explicit command, but it's not mandatory because those are already the defaults for peak_detect, tonemapping, gamut_mode, and dithering. (Strictly speaking, tonemapping is set to "auto," using "spline" at present.)

Code:
-vf libplacebo=upscaler=spline36:downscaler=spline36:w=-1:h=1080:
    peak_detect=true:tonemapping=spline:gamut_mode=perceptual:
    colorspace=bt709:color_trc=bt709:color_primaries=bt709:range=limited:dithering=blue:
    format=yuv420p,crop=%crop%:exact=true,sidedata=delete
GeoffreyA is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:51.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.