VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. Hello, everyone!

    If you own an RTX 20xx or higher GPU, you can easily convert SDR videos to HDR using NVIDIA’s AI-enhanced tools — no expensive software required.
    The process leverages Rigaya NVEnc with NVIDIA AI to deliver high-quality results.

    Here’s how to get started:

    What You Need
    Latest Rigaya NVEnc 64-bit version, download it here (make sure to use the 64-bit version):
    Code:
    https://github.com/rigaya/NVEnc/releases
    Latest NVIDIA GPU driver:
    Ensure your driver is up to date. Minimum required version: 550.58.

    NVIDIA Video Effect models and runtime dependencies for your GPU model:
    Code:
    https://www.nvidia.com/broadcast-sdk-resources

    Setting Up an Option File
    To simplify the encoding process, create an option file with all necessary settings:

    Create a text file and name it (e.g.): SDR2HDR.txt.

    Copy and paste the following content into the file:

    Code:
    --avhw
    --vbr 50000
    --ref 8
    --bframes 5
    --output-depth 10
    --pic-struct
    --audio-copy
    --chapter-copy
    --atc-sei auto
    --vpp-ngx-truehdr contrast=100,saturation=100,middlegray=50,maxluminance=1000
    --master-display G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)
    --colormatrix bt2020nc 
    --colorprim bt2020 
    --transfer smpte2084
    --max-cll 1000,300
    --codec hevc 
    --level 5.1 
    --profile main10 
    --tier high
    Each option in the file has a specific purpose. Here’s an explanation:

    Code:
    --avhw
    Enables hardware acceleration, allowing the encoding process to use your NVIDIA GPU for faster performance.

    Code:
    --vbr 50000
    Sets the variable bitrate (VBR) to 50 Mbps, which adjusts dynamically for optimal quality and compression.

    Lower values reduce file size but may decrease quality.
    Higher values improve quality at the cost of larger file sizes.

    Code:
    --ref 8
    Defines the number of reference frames used for efficient prediction and compression.


    Code:
    --bframes 5
    Specifies the number of B-frames.
    It improves compression efficiency and quality but increases encoding time.

    Code:
    --output-depth 10
    Outputs a 10-bit video file, crucial for HDR, as it provides smoother gradients and a broader range of colors.

    Code:
    --vpp-ngx-truehdr
    Activates NVIDIA AI-powered SDR to HDR conversion using TrueHDR.

    Includes adjustable parameters:

    contrast: Light/dark difference (default: 100).
    saturation: Color intensity (default: 100).
    middlegray: Midtone brightness (default: 50).
    maxluminance: Peak brightness in nits (default: 1000).

    Code:
    --master-display
    Adds HDR10 metadata for consistent colour calibration and brightness across HDR displays:

    G, B, R: Color primaries (green, blue, red).
    WP: White point coordinates.
    L: Luminance range (max and min brightness in nits).

    Code:
    --colormatrix, --colorprim, --transfer
    Converts the video’s color space from SDR (bt709) to HDR10 (bt2020):

    Code:
    --colormatrix bt2020nc
    : Converts colors to HDR.
    Code:
    --colorprim bt2020
    : Defines HDR color primaries.
    Code:
    --transfer smpte2084
    : Uses the HDR10 PQ transfer function.

    Code:
    --codec hevc
    Encodes the video in the HEVC (H.265) format, which is efficient and required for UHD HDR.

    Code:
    --level, --profile, --tier
    Specifies HDR encoding parameters:

    Level: Defines encoding complexity (e.g., 5.1 for UHD HDR).
    Profile: Use main10 for 10-bit HDR content.
    Tier: Set to high for improved quality.

    Batch Processing with Command Line
    You can batch-convert multiple SDR files to HDR in a folder using this command:

    Code:
    for /R %i in (*.mp4 *.mkv) do "D:\rigaya\NVENC\NVEncC64.exe" -i "%i" --option-file "D:\rigaya\SDR2HDR.txt" -o "G:\%~pi%~ni.mkv"
    What it does:

    for /R %i in (*.mp4 *.mkv): Loops through all MP4 and MKV files in the folder and its subfolders.
    -i "%i": Specifies the input file.
    --option-file "D:\rigaya\SDR2HDR.txt": Uses the settings in your SDR2HDR.txt file.
    -o "G:\%~pi%~ni.mkv": Outputs the converted file to the specified folder, retaining the original structure and file name.

    Example MediaInfo
    Here’s an example of what the MediaInfo output for a converted file might look like.


    Code:
    Format                                   : HEVC
    Format/Info                              : High Efficiency Video Coding
    Format profile                           : Main 10@L5.1@High
    HDR format                               : SMPTE ST 2086, HDR10 compatible
    Codec ID                                 : V_MPEGH/ISO/HEVC
    Duration                                 : 2:00:49
    Bit rate                                 : 42.4 Mb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 2.40:1
    Frame rate mode                          : Constant
    Frame rate                               : 23.976 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 10 bits
    Bits/(Pixel*Frame)                       : 1.152
    Stream size                              : 44.6 GiB
    Default                                  : Yes
    Forced                                   : No
    Color range                              : Limited
    Color primaries                          : BT.2020
    Transfer characteristics                 : PQ
    Matrix coefficients                      : BT.2020 non-constant
    Mastering display color primaries        : Display P3
    Mastering display luminance              : min: 0.0001 cd/m2, max: 1000 cd/m2
    Maximum Content Light Level              : 1000 cd/m2
    Maximum Frame-Average Light Level        : 300 cd/m2
    This output confirms HDR10 encoding with correct metadata and properties.


    Additional Notes
    Test on small files first: Avoid wasting time on long encodes by experimenting with short clips initially.
    Adjust settings: Modify options like contrast, saturation, or bitrate in the SDR2HDR.txt file to meet your preferences.
    More options: Rigaya NVEnc supports additional features like upscaling, cropping, and padding. Learn more here:
    Code:
    https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md

    Create UHD Content
    Once you’ve converted your SDR files to HDR, you can use tools like BDRebuilder to compile the output files into UHD content.

    Disclaimer
    I’ve done my best to provide accurate information and instructions, but I’m only human.
    If you notice any errors, mistakes, or areas for improvement, please let me know, and I’ll be happy to fix and correct them!

    Enjoy converting SDR to HDR with NVIDIA AI, and feel free to ask questions.
    Last edited by dietboby; 20th Nov 2024 at 00:49.
    Quote Quote  
  2. Any chance of posting before and after samples?
    Quote Quote  
  3. Since the purpose of your procedure is to upscale shouldn't you include the upscaled frame size in your encoding parameters? Include for example "--output-res 1440x1080" in your SDR2HDR.txt file or the NVEncC64 command line.
    Quote Quote  
  4. Originally Posted by jagabo View Post
    Since the purpose of your procedure is to upscale shouldn't you include the upscaled frame size in your encoding parameters? Include for example "--output-res 1440x1080" in your SDR2HDR.txt file or the NVEncC64 command line.
    Thank you for your feedback
    You are correct; I did not include upscaling in the script.
    This guide focused specifically on converting SDR to HDR, as HDR can be effectively applied to 1080p material without requiring upscaling.

    However, upscaling is undoubtedly possible if desired.
    For instance, adding a parameter like
    Code:
    --output-res 1440x1080
    (or any target resolution) can achieve this.
    I should have mentioned this option in the guide—thank you for pointing that out.

    It’s also important to note that care must be taken when upscaling cropped files, as it can lead to distortions or misalignments.
    For example, if a file has a resolution of 1920x800 and is resized to 1440x1080, the aspect ratio will be incorrect.

    To upscale correctly, padding must be applied before resizing to maintain the original aspect ratio.
    Padding is applied to the original resolution, not the output resolution.

    How to Calculate Padding for Correct Aspect Ratio

    To calculate the padding required for upscaling:

    Use a tool like MediaInfo to find the original resolution of the video.
    Determine the target resolution:
    For 1080p, the target resolution is 1920x1080.
    For UHD 4K, the target resolution is 3840x2160.

    Calculate the missing pixels for padding:

    Horizontal Padding: If the original width is less than the target width, calculate (target-width - original-width) and divide by 2 to apply equal padding on the left and right sides.
    Vertical Padding: If the original height is less than the target height, calculate (target-height - original-height) and divide by 2 to apply equal padding on the top and bottom.

    Example Calculation:
    If the original resolution is 1920x800 and the target is 1920x1080:

    Missing height:
    1080−800=280

    Padding for the top and bottom:
    280/2=140

    The command for padding:

    Code:
    --vpp-pad 0,140,0,140

    If the video also requires horizontal padding, for example, going from 1600x1080 to 1920x1080:

    Missing width:
    1920−1600=320

    Padding for the left and right:
    320/2=160

    The command for padding:

    Code:
    --vpp-pad 160,0,160,0
    Resizing Options
    You can resize the video using the appropriate upscaling algorithm.
    Rigaya NVEnc supports several options for resizing, each with its strengths.
    Here are a few examples:

    NVIDIA Video Effects Super Resolution (nvvfx-superres):
    Code:
    --vpp-resize algo=nvvfx-superres,superres-mode=1
    NVIDIA NGX Video Super Resolution (Best Quality):
    Code:
    --vpp-resize algo=ngx-vsr,vsr-quality=4
    Libplacebo Resize Filters (High-quality sinc filter):
    Code:
    --vpp-resize algo=libplacebo-sinc,pl-radius=3.0,pl-antiring=0.5
    Thank you again for your valuable feedback.
    Quote Quote  
  5. Originally Posted by dietboby View Post
    Originally Posted by jagabo View Post
    Since the purpose of your procedure is to upscale shouldn't you include the upscaled frame size in your encoding parameters? Include for example "--output-res 1440x1080" in your SDR2HDR.txt file or the NVEncC64 command line.
    This guide focused specifically on converting SDR to HDR, as HDR can be effectively applied to 1080p material without requiring upscaling.
    Oops, sorry. I thought you were upscaling too. Thanks for the upscaling tips though. I tried a quick DVD to HD upscale with --vpp-resize algo=ngx-vsr,vsr-quality=4 and it looked pretty good.
    Quote Quote  
  6. Member
    Join Date
    Sep 2019
    Location
    Cleveland, Ohio
    Search Comp PM
    I just assume that you would upscale with something like Topaz first, and then apply the HDR. Not sure what having an upscale done by the GPU alone would even look like.
    Quote Quote  
  7. Originally Posted by C.C. 95 View Post
    I just assume that you would upscale with something like Topaz first, and then apply the HDR. Not sure what having an upscale done by the GPU alone would even look like.

    I understand your point about using software like Topaz for upscaling; however, I’m not using it as it comes with a cost, and my approach focuses on solutions that require no additional expense.
    Quote Quote  
  8. Member
    Join Date
    Sep 2019
    Location
    Cleveland, Ohio
    Search Comp PM
    Originally Posted by dietboby View Post
    Originally Posted by C.C. 95 View Post
    I just assume that you would upscale with something like Topaz first, and then apply the HDR. Not sure what having an upscale done by the GPU alone would even look like.

    I understand your point about using software like Topaz for upscaling; however, I’m not using it as it comes with a cost, and my approach focuses on solutions that require no additional expense.
    Fair enough !
    Quote Quote  
  9. @jagabo

    In case you are interested.
    With the libplacebo and shaders you can now also do things like this:


    Code:
    libplacebo-shader: cspconv(yv12(16bit) -> yuv444(16bit))
                                      D:\rigaya\shader\SSimSuperRes.glsl, res=960x720, resampler=libplacebo-ewa-lanczos,
                                      colorsystem=bt601, transfer=bt1886, radius=-1.00, clamp=0.00,
                                      copyDtoD
    libplacebo-shader: copyDtoD
                                      D:\rigaya\shader\SSimSuperRes.glsl, res=1440x1080, resampler=libplacebo-ewa-lanczos,
                                      colorsystem=bt709, transfer=bt1886, radius=-1.00, clamp=0.00,
                                      copyDtoD
    libplacebo shaders will be called in order as set in the config
    Last edited by dietboby; 28th Nov 2024 at 22:18.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!