Skip to content

Commit b9c773b

Browse files
committed
Add nvenc-av1 video mode.
1 parent f6a7d3c commit b9c773b

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ The `svt_av1_10bit` encoder can produce output compatible with the HDR10 and HDR
132132

133133
When using this mode, audio output is in Opus format at slightly lower bitrates. Why Opus? Because it's higher quality than AAC and if you can play AV1 format video then you can certainly play Opus format audio.
134134

135+
### `--mode nvenc-av1`
136+
137+
This mode uses the `nvenc_av1_10bit` Nvidia hardware-based encoder, also with a constant quality ratecontrol system. The output is actually about the same size as that from the software-based `svt_av1_10bit` encoder in `av1` mode, but this is MUCH faster.
138+
139+
Be aware that, like other Nvidia encoders, `nvenc_h265_10bit` can only produce HDR10-compatible output. And like the `av1` mode, audio output is in Opus format at slightly lower bitrates.
140+
135141
> [!NOTE]
136-
> *Additional `--mode` arguments leveraging the `vt_h265_10bit` and `nvenc_av1_10bit` video encoders, likely to be named `vt-hevc` and `nvenc-av1`, are under consideration pending ratecontrol tuning. And tuning of any `vt-hevc` mode implementation will be delayed until I actually have an Apple Silicon Mac. But I'm working on the `nvenc-av1` mode implementation now since I already have the necessary Nvidia hardware.*
142+
> *An additional `--mode` argument leveraging the `vt_h265_10bit` video encoder, likely to be named `vt-hevc`, is under consideration pending ratecontrol tuning which will be delayed until I actually have an Apple Silicon Mac.*
137143
138144
## Calling `HandBrakeCLI` from `transcode-video.rb`
139145

transcode-video.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ def usage
3636
Options:
3737
--debug increase diagnostic information
3838
-n, --dry-run don't transcode, just show `HandBrakeCLI` command
39-
-m, --mode h264|hevc|nvenc-hevc|av1|none
39+
-m, --mode h264|hevc|nvenc-hevc|av1|nvenc-av1|none
4040
set video encoding mode (default: h264)
4141
-p, --preset NAME apply video encoder preset (default: 8 for av1)
4242
-b, --bitrate TARGET set video bitrate target (default: based on input)
4343
-q, --quality VALUE set constant quality value
4444
--no-bframe-refs don't use B-frames as reference frames
4545
(for compatibilty with older Nvidia GPUs)
4646
-a, --audio-mode aac|opus|eac3|none
47-
set audio encoding mode (default: aac, opus for av1)
47+
set audio encoding mode
48+
(default: aac, opus for av1 and nvenc-av1)
4849
--add-audio TRACK|LANGUAGE|STRING|all
4950
include audio track (default: 1)
5051
(can be used multiple times)
@@ -138,11 +139,14 @@ def define_options(opts)
138139
@mode = case arg
139140
when 'h264', 'hevc', 'none'
140141
arg.to_sym
142+
when 'nvenc-hevc'
143+
:nvenc_hevc
141144
when 'av1'
142145
@audio_mode = :opus
143146
:av1
144-
when 'nvenc-hevc'
145-
:nvenc_hevc
147+
when 'nvenc-av1'
148+
@audio_mode = :opus
149+
:nvenc_av1
146150
else
147151
fail UsageError, "unsupported video mode: #{arg}"
148152
end
@@ -467,6 +471,12 @@ def get_video_options(media_info)
467471
end
468472

469473
preset = @preset.nil? ? '8' : [[@preset.to_i, -1].max, 13].min.to_s
474+
when :nvenc_av1
475+
encoder = 'nvenc_av1_10bit'
476+
477+
if @bitrate.nil?
478+
quality = @quality.nil? ? '35' : [[@quality.to_i, 0].max, 63].min.to_s
479+
end
470480
else
471481
quality = @quality
472482
end

0 commit comments

Comments
 (0)