Enable AV1 encoding for nvenc

This commit is contained in:
Kierek
2025-02-20 10:55:23 +01:00
committed by xytovl
parent 163d72dcce
commit 8495a9433c
3 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -223,7 +223,7 @@ Kirigami.ScrollablePage {
{ {
name: "nvenc", name: "nvenc",
label: i18n("nvenc (NVIDIA GPUs)"), label: i18n("nvenc (NVIDIA GPUs)"),
codecs: "auto,h264,h265" codecs: "auto,h264,h265,av1"
}, },
{ {
name: "vaapi", name: "vaapi",
+1 -1
View File
@@ -51,7 +51,7 @@ Identifier of the encoder, one of
Default value: first supported by both headset and encoder of `av1`, `h264`, `h265`. Default value: first supported by both headset and encoder of `av1`, `h264`, `h265`.
One of `h264`, `h265` or `av1`. One of `h264`, `h265` or `av1`.
Not all encoders support every codec, `x264` and `vulkan` only support `h264`, `nvenc` only `h264` and `h265` Not all encoders support every codec, `x264` and `vulkan` only support `h264`.
### `width`, `height`, `offset_x`, `offset_y` (advanced) ### `width`, `height`, `offset_x`, `offset_y` (advanced)
Default values: full image (`width` = 1, `height` = 1, `offset_x` = 0, `offset_y` = 0) Default values: full image (`width` = 1, `height` = 1, `offset_x` = 0, `offset_y` = 0)
+6 -3
View File
@@ -129,7 +129,7 @@ static auto encode_guid(video_codec codec)
case h265: case h265:
return NV_ENC_CODEC_HEVC_GUID; return NV_ENC_CODEC_HEVC_GUID;
case av1: case av1:
throw std::runtime_error("AV1 not implemented on nvenc"); return NV_ENC_CODEC_AV1_GUID;
} }
throw std::out_of_range("Invalid codec " + std::to_string(codec)); throw std::out_of_range("Invalid codec " + std::to_string(codec));
} }
@@ -176,6 +176,7 @@ video_encoder_nvenc::video_encoder_nvenc(
break; break;
case video_codec::av1: case video_codec::av1:
printf("%d AV1 presets\n", count);
break; break;
} }
@@ -225,6 +226,9 @@ video_encoder_nvenc::video_encoder_nvenc(
params.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag = 1; params.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag = 1;
break; break;
case video_codec::av1: case video_codec::av1:
params.encodeCodecConfig.av1Config.repeatSeqHdr = 1;
params.encodeCodecConfig.av1Config.maxNumRefFramesInDPB = 0;
params.encodeCodecConfig.av1Config.idrPeriod = NVENC_INFINITE_GOPLENGTH;
break; break;
} }
@@ -241,8 +245,7 @@ video_encoder_nvenc::video_encoder_nvenc(
.enableEncodeAsync = 0, .enableEncodeAsync = 0,
.enablePTD = 1, .enablePTD = 1,
.encodeConfig = &params, .encodeConfig = &params,
.tuningInfo = tuningInfo .tuningInfo = tuningInfo};
};
NVENC_CHECK(fn.nvEncInitializeEncoder(session_handle, &params2)); NVENC_CHECK(fn.nvEncInitializeEncoder(session_handle, &params2));
NV_ENC_CREATE_BITSTREAM_BUFFER params3{ NV_ENC_CREATE_BITSTREAM_BUFFER params3{