0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

UI: Simple Output Mode for NVENC HEVC

This commit is contained in:
Yuriy Chumak 2022-05-19 07:53:37 +03:00 committed by Jim
parent 29782cd594
commit 84e7db5059
5 changed files with 104 additions and 0 deletions

View File

@ -897,6 +897,7 @@ Basic.Settings.Output.Simple.Encoder.Software="Software (x264)"
Basic.Settings.Output.Simple.Encoder.Hardware.QSV.H264="Hardware (QSV, H.264)" 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.H264="Hardware (AMD, H.264)"
Basic.Settings.Output.Simple.Encoder.Hardware.NVENC.H264="Hardware (NVENC, H.264)" Basic.Settings.Output.Simple.Encoder.Hardware.NVENC.H264="Hardware (NVENC, H.264)"
Basic.Settings.Output.Simple.Encoder.Hardware.NVENC.HEVC="Hardware (NVENC, HEVC)"
Basic.Settings.Output.Simple.Encoder.SoftwareLowCPU="Software (x264 low CPU usage preset, increases file size)" Basic.Settings.Output.Simple.Encoder.SoftwareLowCPU="Software (x264 low CPU usage preset, increases file size)"
Basic.Settings.Output.Simple.TwitchVodTrack="Twitch VOD Track (Uses Track 2)" Basic.Settings.Output.Simple.TwitchVodTrack="Twitch VOD Track (Uses Track 2)"
Basic.Settings.Output.Warn.EnforceResolutionFPS.Title="Incompatible Resolution/Framerate" Basic.Settings.Output.Warn.EnforceResolutionFPS.Title="Incompatible Resolution/Framerate"

View File

@ -285,6 +285,9 @@ struct SimpleOutput : BasicOutputHandler {
void UpdateRecordingSettings_x264_crf(int crf); void UpdateRecordingSettings_x264_crf(int crf);
void UpdateRecordingSettings_qsv11(int crf); void UpdateRecordingSettings_qsv11(int crf);
void UpdateRecordingSettings_nvenc(int cqp); void UpdateRecordingSettings_nvenc(int cqp);
#ifdef ENABLE_HEVC
void UpdateRecordingSettings_nvenc_hevc(int cqp);
#endif
void UpdateRecordingSettings_amd_cqp(int cqp); void UpdateRecordingSettings_amd_cqp(int cqp);
void UpdateRecordingSettings(); void UpdateRecordingSettings();
void UpdateRecordingAudioSettings(); void UpdateRecordingAudioSettings();
@ -392,6 +395,13 @@ void SimpleOutput::LoadRecordingPreset()
? "jim_nvenc" ? "jim_nvenc"
: "ffmpeg_nvenc"; : "ffmpeg_nvenc";
LoadRecordingPreset_Lossy(id); LoadRecordingPreset_Lossy(id);
#ifdef ENABLE_HEVC
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
const char *id = EncoderAvailable("jim_hevc_nvenc")
? "jim_hevc_nvenc"
: "ffmpeg_hevc_nvenc";
LoadRecordingPreset_Lossy(id);
#endif
} }
usingRecordingPreset = true; usingRecordingPreset = true;
@ -420,6 +430,14 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
: "ffmpeg_nvenc"; : "ffmpeg_nvenc";
LoadStreamingPreset_Lossy(id); LoadStreamingPreset_Lossy(id);
#ifdef ENABLE_HEVC
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
const char *id = EncoderAvailable("jim_hevc_nvenc")
? "jim_hevc_nvenc"
: "ffmpeg_hevc_nvenc";
LoadStreamingPreset_Lossy(id);
#endif
} else { } else {
LoadStreamingPreset_Lossy("obs_x264"); LoadStreamingPreset_Lossy("obs_x264");
} }
@ -519,6 +537,11 @@ void SimpleOutput::Update()
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) { } else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) {
presetType = "NVENCPreset"; presetType = "NVENCPreset";
#ifdef ENABLE_HEVC
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
presetType = "NVENCPreset";
#endif
} else { } else {
presetType = "Preset"; presetType = "Preset";
} }
@ -655,6 +678,19 @@ void SimpleOutput::UpdateRecordingSettings_nvenc(int cqp)
obs_encoder_update(videoRecording, settings); obs_encoder_update(videoRecording, settings);
} }
#ifdef ENABLE_HEVC
void SimpleOutput::UpdateRecordingSettings_nvenc_hevc(int cqp)
{
OBSDataAutoRelease settings = obs_data_create();
obs_data_set_string(settings, "rate_control", "CQP");
obs_data_set_string(settings, "profile", "main");
obs_data_set_string(settings, "preset", "hq");
obs_data_set_int(settings, "cqp", cqp);
obs_encoder_update(videoRecording, settings);
}
#endif
void SimpleOutput::UpdateStreamingSettings_amd(obs_data_t *settings, void SimpleOutput::UpdateStreamingSettings_amd(obs_data_t *settings,
int bitrate) int bitrate)
{ {
@ -714,6 +750,11 @@ void SimpleOutput::UpdateRecordingSettings()
} else if (videoEncoder == SIMPLE_ENCODER_NVENC) { } else if (videoEncoder == SIMPLE_ENCODER_NVENC) {
UpdateRecordingSettings_nvenc(crf); UpdateRecordingSettings_nvenc(crf);
#ifdef ENABLE_HEVC
} else if (videoEncoder == SIMPLE_ENCODER_NVENC_HEVC) {
UpdateRecordingSettings_nvenc_hevc(crf);
#endif
} }
UpdateRecordingAudioSettings(); UpdateRecordingAudioSettings();
} }

View File

@ -818,6 +818,9 @@ void OBSBasic::CheckForSimpleModeX264Fallback()
bool qsv_supported = false; bool qsv_supported = false;
bool amd_supported = false; bool amd_supported = false;
bool nve_supported = false; bool nve_supported = false;
#ifdef ENABLE_HEVC
bool nve_hevc_supported = false;
#endif
bool changed = false; bool changed = false;
size_t idx = 0; size_t idx = 0;
const char *id; const char *id;
@ -829,6 +832,10 @@ void OBSBasic::CheckForSimpleModeX264Fallback()
qsv_supported = true; qsv_supported = true;
else if (strcmp(id, "ffmpeg_nvenc") == 0) else if (strcmp(id, "ffmpeg_nvenc") == 0)
nve_supported = true; nve_supported = true;
#ifdef ENABLE_HEVC
else if (strcmp(id, "ffmpeg_hevc_nvenc") == 0)
nve_hevc_supported = true;
#endif
} }
auto CheckEncoder = [&](const char *&name) { auto CheckEncoder = [&](const char *&name) {
@ -844,6 +851,14 @@ void OBSBasic::CheckForSimpleModeX264Fallback()
name = SIMPLE_ENCODER_X264; name = SIMPLE_ENCODER_X264;
return false; return false;
} }
#ifdef ENABLE_HEVC
} else if (strcmp(name, SIMPLE_ENCODER_NVENC_HEVC) == 0) {
if (!nve_hevc_supported) {
changed = true;
name = SIMPLE_ENCODER_X264;
return false;
}
#endif
} else if (strcmp(name, SIMPLE_ENCODER_AMD) == 0) { } else if (strcmp(name, SIMPLE_ENCODER_AMD) == 0) {
if (!amd_supported) { if (!amd_supported) {
changed = true; changed = true;

View File

@ -66,6 +66,9 @@ class OBSBasicStats;
#define SIMPLE_ENCODER_X264_LOWCPU "x264_lowcpu" #define SIMPLE_ENCODER_X264_LOWCPU "x264_lowcpu"
#define SIMPLE_ENCODER_QSV "qsv" #define SIMPLE_ENCODER_QSV "qsv"
#define SIMPLE_ENCODER_NVENC "nvenc" #define SIMPLE_ENCODER_NVENC "nvenc"
#ifdef ENABLE_HEVC
#define SIMPLE_ENCODER_NVENC_HEVC "nvenc_hevc"
#endif
#define SIMPLE_ENCODER_AMD "amd" #define SIMPLE_ENCODER_AMD "amd"
#define PREVIEW_EDGE_SIZE 10 #define PREVIEW_EDGE_SIZE 10

View File

@ -3551,6 +3551,10 @@ void OBSBasicSettings::SaveOutputSettings()
presetType = "QSVPreset"; presetType = "QSVPreset";
else if (encoder == SIMPLE_ENCODER_NVENC) else if (encoder == SIMPLE_ENCODER_NVENC)
presetType = "NVENCPreset"; presetType = "NVENCPreset";
#ifdef ENABLE_HEVC
else if (encoder == SIMPLE_ENCODER_NVENC_HEVC)
presetType = "NVENCPreset";
#endif
else if (encoder == SIMPLE_ENCODER_AMD) else if (encoder == SIMPLE_ENCODER_AMD)
presetType = "AMDPreset"; presetType = "AMDPreset";
else else
@ -4769,6 +4773,12 @@ void OBSBasicSettings::FillSimpleRecordingValues()
ui->simpleOutRecEncoder->addItem( ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.NVENC.H264"), ENCODER_STR("Hardware.NVENC.H264"),
QString(SIMPLE_ENCODER_NVENC)); QString(SIMPLE_ENCODER_NVENC));
#ifdef ENABLE_HEVC
if (EncoderAvailable("ffmpeg_hevc_nvenc"))
ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.NVENC.HEVC"),
QString(SIMPLE_ENCODER_NVENC_HEVC));
#endif
if (EncoderAvailable("amd_amf_h264")) if (EncoderAvailable("amd_amf_h264"))
ui->simpleOutRecEncoder->addItem( ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.AMD.H264"), ENCODER_STR("Hardware.AMD.H264"),
@ -4788,6 +4798,12 @@ void OBSBasicSettings::FillSimpleStreamingValues()
ui->simpleOutStrEncoder->addItem( ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.NVENC.H264"), ENCODER_STR("Hardware.NVENC.H264"),
QString(SIMPLE_ENCODER_NVENC)); QString(SIMPLE_ENCODER_NVENC));
#ifdef ENABLE_HEVC
if (EncoderAvailable("ffmpeg_hevc_nvenc"))
ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.NVENC.HEVC"),
QString(SIMPLE_ENCODER_NVENC_HEVC));
#endif
if (EncoderAvailable("amd_amf_h264")) if (EncoderAvailable("amd_amf_h264"))
ui->simpleOutStrEncoder->addItem( ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.AMD.H264"), ENCODER_STR("Hardware.AMD.H264"),
@ -4870,6 +4886,34 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged()
defaultPreset = "default"; defaultPreset = "default";
preset = curNVENCPreset; preset = curNVENCPreset;
#ifdef ENABLE_HEVC
} else if (encoder == SIMPLE_ENCODER_NVENC_HEVC) {
obs_properties_t *props =
obs_get_encoder_properties("ffmpeg_hevc_nvenc");
obs_property_t *p = obs_properties_get(props, "preset");
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);
}
obs_properties_destroy(props);
defaultPreset = "default";
preset = curNVENCPreset;
#endif
} else if (encoder == SIMPLE_ENCODER_AMD) { } else if (encoder == SIMPLE_ENCODER_AMD) {
ui->simpleOutPreset->addItem("Speed", "speed"); ui->simpleOutPreset->addItem("Speed", "speed");
ui->simpleOutPreset->addItem("Balanced", "balanced"); ui->simpleOutPreset->addItem("Balanced", "balanced");