UI: Add NVENC AV1 to simple output mode

This commit is contained in:
jp9000
2022-09-19 01:55:19 -07:00
committed by Jim
parent 53f4627b0c
commit 614bf960d9
6 changed files with 39 additions and 20 deletions

View File

@@ -946,6 +946,7 @@ Basic.Settings.Output.Simple.Encoder.Hardware.QSV.H264="Hardware (QSV, H.264)"
Basic.Settings.Output.Simple.Encoder.Hardware.AMD.H264="Hardware (AMD, H.264)"
Basic.Settings.Output.Simple.Encoder.Hardware.AMD.HEVC="Hardware (AMD, HEVC)"
Basic.Settings.Output.Simple.Encoder.Hardware.NVENC.H264="Hardware (NVENC, H.264)"
Basic.Settings.Output.Simple.Encoder.Hardware.NVENC.AV1="Hardware (NVENC, AV1)"
Basic.Settings.Output.Simple.Encoder.Hardware.NVENC.HEVC="Hardware (NVENC, HEVC)"
Basic.Settings.Output.Simple.Encoder.Hardware.Apple.H264="Hardware (Apple, H.264)"
Basic.Settings.Output.Simple.Encoder.SoftwareLowCPU="Software (x264 low CPU usage preset, increases file size)"

View File

@@ -290,9 +290,7 @@ struct SimpleOutput : BasicOutputHandler {
void UpdateRecordingSettings_x264_crf(int crf);
void UpdateRecordingSettings_qsv11(int crf);
void UpdateRecordingSettings_nvenc(int cqp);
#ifdef ENABLE_HEVC
void UpdateRecordingSettings_nvenc_hevc(int cqp);
#endif
void UpdateRecordingSettings_nvenc_hevc_av1(int cqp);
void UpdateRecordingSettings_amd_cqp(int cqp);
void UpdateRecordingSettings_apple(int quality);
void UpdateRecordingSettings();
@@ -384,6 +382,8 @@ const char *get_simple_output_encoder(const char *encoder)
return EncoderAvailable("jim_hevc_nvenc") ? "jim_hevc_nvenc"
: "ffmpeg_hevc_nvenc";
#endif
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_AV1) == 0) {
return "jim_av1_nvenc";
} else if (strcmp(encoder, SIMPLE_ENCODER_APPLE_H264) == 0) {
return "com.apple.videotoolbox.videoencoder.ave.avc";
}
@@ -542,6 +542,9 @@ void SimpleOutput::Update()
presetType = "NVENCPreset";
#endif
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_AV1) == 0) {
presetType = "NVENCPreset";
} else {
presetType = "Preset";
}
@@ -676,8 +679,7 @@ void SimpleOutput::UpdateRecordingSettings_nvenc(int cqp)
obs_encoder_update(videoRecording, settings);
}
#ifdef ENABLE_HEVC
void SimpleOutput::UpdateRecordingSettings_nvenc_hevc(int cqp)
void SimpleOutput::UpdateRecordingSettings_nvenc_hevc_av1(int cqp)
{
OBSDataAutoRelease settings = obs_data_create();
obs_data_set_string(settings, "rate_control", "CQP");
@@ -686,7 +688,6 @@ void SimpleOutput::UpdateRecordingSettings_nvenc_hevc(int cqp)
obs_encoder_update(videoRecording, settings);
}
#endif
void SimpleOutput::UpdateRecordingSettings_apple(int quality)
{
@@ -732,8 +733,11 @@ void SimpleOutput::UpdateRecordingSettings()
#ifdef ENABLE_HEVC
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_HEVC) {
UpdateRecordingSettings_nvenc_hevc(crf);
UpdateRecordingSettings_nvenc_hevc_av1(crf);
#endif
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_AV1) {
UpdateRecordingSettings_nvenc_hevc_av1(crf);
} else if (videoEncoder == SIMPLE_ENCODER_APPLE_H264) {
/* These are magic numbers. 0 - 100, more is better. */
UpdateRecordingSettings_apple(ultra_hq ? 70 : 50);

View File

@@ -862,6 +862,12 @@ void OBSBasic::CheckForSimpleModeX264Fallback()
name = SIMPLE_ENCODER_X264;
return false;
}
} else if (strcmp(name, SIMPLE_ENCODER_NVENC_AV1) == 0) {
if (!nve_supported) {
changed = true;
name = SIMPLE_ENCODER_X264;
return false;
}
#ifdef ENABLE_HEVC
} else if (strcmp(name, SIMPLE_ENCODER_AMD_HEVC) == 0) {
if (!amd_hevc_supported) {

View File

@@ -66,6 +66,7 @@ class OBSBasicStats;
#define SIMPLE_ENCODER_X264_LOWCPU "x264_lowcpu"
#define SIMPLE_ENCODER_QSV "qsv"
#define SIMPLE_ENCODER_NVENC "nvenc"
#define SIMPLE_ENCODER_NVENC_AV1 "nvenc_av1"
#define SIMPLE_ENCODER_NVENC_HEVC "nvenc_hevc"
#define SIMPLE_ENCODER_AMD "amd"
#define SIMPLE_ENCODER_AMD_HEVC "amd_hevc"

View File

@@ -1250,6 +1250,8 @@ static QString get_simple_fallback(const QString &enc)
{
if (enc == SIMPLE_ENCODER_NVENC_HEVC)
return SIMPLE_ENCODER_NVENC;
if (enc == SIMPLE_ENCODER_NVENC_AV1)
return SIMPLE_ENCODER_NVENC;
if (enc == SIMPLE_ENCODER_AMD_HEVC)
return SIMPLE_ENCODER_AMD;
return SIMPLE_ENCODER_X264;
@@ -1385,6 +1387,10 @@ void OBSBasicSettings::ResetEncoders(bool streamOnly)
ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.NVENC.H264"),
QString(SIMPLE_ENCODER_NVENC));
if (service_supports_encoder(codecs, "jim_av1_nvenc"))
ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.NVENC.AV1"),
QString(SIMPLE_ENCODER_NVENC));
#ifdef ENABLE_HEVC
if (service_supports_encoder(codecs, "h265_texture_amf"))
ui->simpleOutStrEncoder->addItem(

View File

@@ -3519,6 +3519,8 @@ void OBSBasicSettings::SaveOutputSettings()
presetType = "QSVPreset";
else if (encoder == SIMPLE_ENCODER_NVENC)
presetType = "NVENCPreset";
else if (encoder == SIMPLE_ENCODER_NVENC_AV1)
presetType = "NVENCPreset";
#ifdef ENABLE_HEVC
else if (encoder == SIMPLE_ENCODER_AMD_HEVC)
presetType = "AMDPreset";
@@ -4765,6 +4767,10 @@ void OBSBasicSettings::FillSimpleRecordingValues()
ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.NVENC.H264"),
QString(SIMPLE_ENCODER_NVENC));
if (EncoderAvailable("jim_av1_nvenc"))
ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.NVENC.AV1"),
QString(SIMPLE_ENCODER_NVENC_AV1));
#ifdef ENABLE_HEVC
if (EncoderAvailable("h265_texture_amf"))
ui->simpleOutRecEncoder->addItem(
@@ -4824,6 +4830,8 @@ void OBSBasicSettings::SimpleRecordingQualityChanged()
SimpleReplayBufferChanged();
}
extern const char *get_simple_output_encoder(const char *encoder);
void OBSBasicSettings::SimpleStreamingEncoderChanged()
{
QString encoder = ui->simpleOutStrEncoder->currentData().toString();
@@ -4844,26 +4852,19 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged()
preset = curQSVPreset;
} else if (encoder == SIMPLE_ENCODER_NVENC ||
encoder == SIMPLE_ENCODER_NVENC_HEVC) {
const char *name = encoder == SIMPLE_ENCODER_NVENC
? "ffmpeg_nvenc"
: "ffmpeg_hevc_nvenc";
encoder == SIMPLE_ENCODER_NVENC_HEVC ||
encoder == SIMPLE_ENCODER_NVENC_AV1) {
const char *name =
get_simple_output_encoder(QT_TO_UTF8(encoder));
obs_properties_t *props = obs_get_encoder_properties(name);
obs_property_t *p = obs_properties_get(props, "preset");
obs_property_t *p = obs_properties_get(props, "preset2");
size_t num = obs_property_list_item_count(p);
for (size_t i = 0; i < num; i++) {
const char *name = obs_property_list_item_name(p, i);
const char *val = obs_property_list_item_string(p, i);
/* bluray is for ideal bluray disc recording settings,
* not streaming */
if (strcmp(val, "bd") == 0)
continue;
/* lossless should of course not be used to stream */
if (astrcmp_n(val, "lossless", 8) == 0)
continue;
ui->simpleOutPreset->addItem(QT_UTF8(name), val);
}