Hello Community,
After many questions, I created a separate thread focusing on NVIDIA video enhancement from the original thread here:
https://forum.redfox.bz/threads/reencoding-videos-via-free-command-line-tools-and-gpu.88489/
This thread is mainly for those who own NVIDIA RTX20xx series GPUs (or later) and prefer command-line interfaces to GUI-based tools.
Why This Might Be for You:
What You Need:
Installation & Setup:
Things you need to adjust
Please note that the setting
If your subtitle is ending like
You can find additional subtitle settings here:
You can copy and place the bat file into the folder with the MP4 and execute it to start the encoding process. Ensure that you have enough hard disk space available.
Considerations:
After many questions, I created a separate thread focusing on NVIDIA video enhancement from the original thread here:
https://forum.redfox.bz/threads/reencoding-videos-via-free-command-line-tools-and-gpu.88489/
This thread is mainly for those who own NVIDIA RTX20xx series GPUs (or later) and prefer command-line interfaces to GUI-based tools.
Why This Might Be for You:
- Cost-Effective: Utilizes your existing NVIDIA hardware; no need for additional expensive AI software.
- Quality Enhancement: Leverages NVIDIA's AI to upscale and denoise videos.
What You Need:
- NVIDIA RTX 20xx GPU or later
- Latest NVIDIA Drivers: Ensure your GPU drivers are up to date.
- Video Effect Models and Runtime Dependencies: Download the latest versions suitable for your GPU from NVIDIA's Resource Page
Code:
https://www.nvidia.com/en-sg/geforce/broadcasting/broadcast-sdk/resources/
- Rigaya NVENC: Get the latest release from Rigaya's GitHub
Code:
https://github.com/rigaya/NVEnc/releases
Installation & Setup:
- Install the NVIDIA drivers and Video Effect models.
- Extract the Rigaya NVENC files to a designated folder.
- In the same folder, create a text file named enhance.txt.
- Copy and paste the following command-line arguments into enhance.txt:
Code:--avsw --codec hevc --cqp 20:22:25 --output-res -2x1080 --vpp-resize nvvfx-superres --preset quality --output-depth 10 --lookahead 32 --bframes 5 --ref 6 --multiref-l0 7 --multiref-l1 3 --bref-mode each --mv-precision Q-pel --level auto --profile main10 --colormatrix auto --colorprim auto --transfer auto --chromaloc auto --max-cll copy --master-display copy --atc-sei auto --dhdr10-info copy --aud --repeat-headers --pic-struct --split-enc auto_forced --audio-copy --audio-disposition copy --audio-metadata copy --chapter-copy --vpp-deband --vpp-nvvfx-denoise --vpp-nvvfx-artifact-reduction
A brief overview of the settings.- --avsw: Read input file using avformat + ffmpeg's software decoder.
- --codec hevc: Set the output video codec to HEVC (H.265).
- --cqp 20:22:25: Use the Constant Quantization Parameter (CQP) rate control method with specified QP values for I, P, and B frames.
- --output-res -2x1080: Set the output resolution, maintaining the aspect ratio and setting the height to 1080 pixels.
- --vpp-resize nvvfx-superres: Use NVIDIA's VFX super-resolution for resizing.
- --preset quality: Use the "quality" preset for encoding, prioritising video quality over encoding speed.
- --output-depth 10: Set the output video bit depth to 10 bits per color channel.
- --lookahead 32: Enable lookahead with 32 frames to improve quality by analyzing future frames.
- --bframes 5: Set the maximum number of consecutive B-frames to 5.
- --ref 6: Use 6 reference frames for prediction.
- --multiref-l0 7 and --multiref-l1 3: Set the number of multi-references for list 0 and list 1 in B-frames.
- --bref-mode each: Use each B-frame as a reference for other frames.
- --mv-precision Q-pel: Set the motion vector precision to quarter-pixel.
- --level auto: Automatically set the encoder level based on other settings and input.
- --profile main10: Use the Main 10 profile for HEVC, which supports 10-bit color depth.
- --colormatrix auto, --colorprim auto, --transfer auto, --chromaloc auto: Copy color matrix, color primaries, transfer characteristics, and chroma sample location based on the input or defaults.
- --max-cll copy, --master-display copy: Copy the Max CLL (Maximum Content Light Level) and Mastering Display Color Volume metadata from the source if available.
- --atc-sei auto, --dhdr10-info copy: Automatically handle ATC SEI (Alternative Transfer Characteristics SEI) and copy dynamic HDR10+ information if present.
- --aud, --repeat-headers: Insert Access Unit Delimiters and repeat VPS, SPS, and PPS headers at every IDR frame.
- --pic-struct: Signal picture structure (frame or field) in the encoded stream.
- --split-enc auto_forced: Automatically decide on using split encoding.
- --audio-copy, --audio-disposition copy, --audio-metadata copy: Copy audio tracks, their dispositions, and metadata from the source.
- --chapter-copy: Copy chapter information from the source.
- --vpp-deband: Apply a debanding filter to reduce banding artifacts.
- --vpp-nvvfx-denoise: Use NVIDIA VFX denoising.
- --vpp-nvvfx-artifact-reduction: Use NVIDIA MAXINE VideoEffects SDK's artefact reduction filter to decrease encoding artefacts.
You can modify any of the settings. These settings you should consider changing. --avsw
change to--avhw
- Reads using avformat + cuvid hardware decoder. This mode will provide maximum performance since the entire transcoding process will run on the GPU--cqp 20:22:25
- Adjust values to increase or decrease compression: Lower setting equals less compression and larger files, and vice versa.--vpp-resize nvvfx-superres
- The strength can be adjusted example:--vpp-resize algo=nvvfx-superres,superres-mode=1
more hereCode:https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#--vpp-resize-string-or-param1value1param2value2
--vpp-nvvfx-denoise
- The strength of the filter can be adjusted--vpp-nvvfx-denoise strength=1
,1 =Stronger effect, which places a higher emphasis on noise removal. More hereCode:https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#--vpp-nvvfx-denoise-param1value1param2value2
--vpp-nvvfx-artifact-reduction
- Using `mode=0` will result in a less aggressive filter better suited for higher bitrates.- You can adjust any setting and see the effects; all settings are located here:
Code:
https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#
Code:
@echo off
REM Set the paths directly without prompting for user input
set "EncoderPath=E:\rigaya\NVEncC\NVEncC64.exe"
set "TxtFilePath=E:\rigaya\enhance.txt"
set "OutputPath=D:\encode"
REM This batch file encodes all MP4 files in the current directory using NVEncC64.exe
REM Subtitles must be named exactly like the video files but with an .srt extension.
REM The output will mirror the folder structure of the input files in the specified output directory.
for %%i in (*.mp4) do (
REM Encoding each MP4 file with subtitles
"%EncoderPath%" -i "%%i" --option-file "%TxtFilePath%" --sub-source "%%~dpni.srt" -o "%OutputPath%\%%~pni.mkv"
)
echo.
echo Encoding complete. Press Enter to exit...
pause > nul
Things you need to adjust
Code:
set "EncoderPath=E:\rigaya\NVEncC\NVEncC64.exe" change to the folder where your NVEncC64.exe is located.
set "TxtFilePath=E:\rigaya\enhance.txt" change to the folder where your enhance.txt is located.
set "OutputPath=D:\encode" change to the folder where you want to encode to.
Please note that the setting
--sub-source "%%~dpni.srt
will look for a subtitle with the ending .srt in the folder of the MP4s with the same name as the MP4.If your subtitle is ending like
.en-us.srt
, you need to adjust it to --sub-source "%%~dpni.en-us.srt
You can find additional subtitle settings here:
Code:
https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#--sub-source-stringintparam1value1
You can copy and place the bat file into the folder with the MP4 and execute it to start the encoding process. Ensure that you have enough hard disk space available.
Considerations:
- Pros: Free, no additional costs, bypasses the need for complex software like Avisynth or Vaporsynth or expensive AI software.
- Cons: There is no GUI; preview requires encoding a specific frame amount; settings may need adjustments based on the video; and enhancements might not work correctly with cartoons or animation. Compared to Avisynth or Vaporsynth, it has certain limitations.