UI: Add NVENC support to simple output

master
jp9000 2016-04-18 16:12:59 -07:00
parent 8e1943065c
commit e3fbdb9293
5 changed files with 64 additions and 1 deletions

View File

@ -390,6 +390,7 @@ Basic.Settings.Output.Simple.Warn.Lossless.Msg="Are you sure you want to use los
Basic.Settings.Output.Simple.Warn.Lossless.Title="Lossless quality warning!" Basic.Settings.Output.Simple.Warn.Lossless.Title="Lossless quality warning!"
Basic.Settings.Output.Simple.Encoder.Software="Software (x264)" Basic.Settings.Output.Simple.Encoder.Software="Software (x264)"
Basic.Settings.Output.Simple.Encoder.Hardware.QSV="Hardware (QSV)" Basic.Settings.Output.Simple.Encoder.Hardware.QSV="Hardware (QSV)"
Basic.Settings.Output.Simple.Encoder.Hardware.NVENC="Hardware (NVENC)"
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.VideoBitrate="Video Bitrate" Basic.Settings.Output.VideoBitrate="Video Bitrate"
Basic.Settings.Output.AudioBitrate="Audio Bitrate" Basic.Settings.Output.AudioBitrate="Audio Bitrate"

View File

@ -154,6 +154,7 @@ 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 bitrate);
void UpdateRecordingSettings(); void UpdateRecordingSettings();
void UpdateRecordingAudioSettings(); void UpdateRecordingAudioSettings();
virtual void Update() override; virtual void Update() override;
@ -245,6 +246,8 @@ void SimpleOutput::LoadRecordingPreset()
lowCPUx264 = true; lowCPUx264 = true;
} else if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) { } else if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) {
LoadRecordingPreset_h264("obs_qsv11"); LoadRecordingPreset_h264("obs_qsv11");
} else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0) {
LoadRecordingPreset_h264("ffmpeg_nvenc");
} }
usingRecordingPreset = true; usingRecordingPreset = true;
@ -267,6 +270,8 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
"StreamEncoder"); "StreamEncoder");
if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0)
LoadStreamingPreset_h264("obs_qsv11"); LoadStreamingPreset_h264("obs_qsv11");
else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0)
LoadStreamingPreset_h264("ffmpeg_nvenc");
else else
LoadStreamingPreset_h264("obs_x264"); LoadStreamingPreset_h264("obs_x264");
@ -330,6 +335,8 @@ void SimpleOutput::Update()
if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0) if (strcmp(encoder, SIMPLE_ENCODER_QSV) == 0)
presetType = "QSVPreset"; presetType = "QSVPreset";
else if (strcmp(encoder, SIMPLE_ENCODER_NVENC) == 0)
presetType = "NVENCPreset";
else else
presetType = "Preset"; presetType = "Preset";
@ -456,15 +463,31 @@ void SimpleOutput::UpdateRecordingSettings_qsv11(int crf)
obs_data_release(settings); obs_data_release(settings);
} }
void SimpleOutput::UpdateRecordingSettings_nvenc(int bitrate)
{
obs_data_t *settings = obs_data_create();
obs_data_set_string(settings, "profile", "high");
obs_data_set_string(settings, "preset", "hq");
obs_data_set_int(settings, "bitrate", bitrate);
obs_encoder_update(h264Recording, settings);
obs_data_release(settings);
}
void SimpleOutput::UpdateRecordingSettings() void SimpleOutput::UpdateRecordingSettings()
{ {
int crf = CalcCRF((videoQuality == "HQ") ? 16 : 23); bool ultra_hq = (videoQuality == "HQ");
int crf = CalcCRF(ultra_hq ? 16 : 23);
if (astrcmp_n(videoEncoder.c_str(), "x264", 4) == 0) { if (astrcmp_n(videoEncoder.c_str(), "x264", 4) == 0) {
UpdateRecordingSettings_x264_crf(crf); UpdateRecordingSettings_x264_crf(crf);
} else if (videoEncoder == SIMPLE_ENCODER_QSV) { } else if (videoEncoder == SIMPLE_ENCODER_QSV) {
UpdateRecordingSettings_qsv11(crf); UpdateRecordingSettings_qsv11(crf);
} else if (videoEncoder == SIMPLE_ENCODER_NVENC) {
UpdateRecordingSettings_nvenc(ultra_hq ? 90000 : 50000);
} }
} }

View File

@ -50,6 +50,7 @@ class QNetworkReply;
#define SIMPLE_ENCODER_X264 "x264" #define SIMPLE_ENCODER_X264 "x264"
#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 PREVIEW_EDGE_SIZE 10 #define PREVIEW_EDGE_SIZE 10

View File

@ -1135,6 +1135,8 @@ void OBSBasicSettings::LoadSimpleOutputSettings()
"Preset"); "Preset");
const char *qsvPreset = config_get_string(main->Config(), "SimpleOutput", const char *qsvPreset = config_get_string(main->Config(), "SimpleOutput",
"QSVPreset"); "QSVPreset");
const char *nvPreset = config_get_string(main->Config(), "SimpleOutput",
"NVENCPreset");
const char *custom = config_get_string(main->Config(), "SimpleOutput", const char *custom = config_get_string(main->Config(), "SimpleOutput",
"x264Settings"); "x264Settings");
const char *recQual = config_get_string(main->Config(), "SimpleOutput", const char *recQual = config_get_string(main->Config(), "SimpleOutput",
@ -1146,6 +1148,7 @@ void OBSBasicSettings::LoadSimpleOutputSettings()
curPreset = preset; curPreset = preset;
curQSVPreset = qsvPreset; curQSVPreset = qsvPreset;
curNVENCPreset = nvPreset;
audioBitrate = FindClosestAvailableAACBitrate(audioBitrate); audioBitrate = FindClosestAvailableAACBitrate(audioBitrate);
@ -2342,6 +2345,8 @@ void OBSBasicSettings::SaveOutputSettings()
if (encoder == SIMPLE_ENCODER_QSV) if (encoder == SIMPLE_ENCODER_QSV)
presetType = "QSVPreset"; presetType = "QSVPreset";
else if (encoder == SIMPLE_ENCODER_NVENC)
presetType = "NVENCPreset";
else else
presetType = "Preset"; presetType = "Preset";
@ -3104,6 +3109,10 @@ void OBSBasicSettings::FillSimpleRecordingValues()
ui->simpleOutRecEncoder->addItem( ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.QSV"), ENCODER_STR("Hardware.QSV"),
QString(SIMPLE_ENCODER_QSV)); QString(SIMPLE_ENCODER_QSV));
if (EncoderAvailable("ffmpeg_nvenc"))
ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.NVENC"),
QString(SIMPLE_ENCODER_NVENC));
#undef ADD_QUALITY #undef ADD_QUALITY
} }
@ -3116,6 +3125,10 @@ void OBSBasicSettings::FillSimpleStreamingValues()
ui->simpleOutStrEncoder->addItem( ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.QSV"), ENCODER_STR("Hardware.QSV"),
QString(SIMPLE_ENCODER_QSV)); QString(SIMPLE_ENCODER_QSV));
if (EncoderAvailable("ffmpeg_nvenc"))
ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.NVENC"),
QString(SIMPLE_ENCODER_NVENC));
#undef ENCODER_STR #undef ENCODER_STR
} }
@ -3149,6 +3162,30 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged()
defaultPreset = "balanced"; defaultPreset = "balanced";
preset = curQSVPreset; preset = curQSVPreset;
} else if (encoder == SIMPLE_ENCODER_NVENC) {
obs_properties_t *props =
obs_get_encoder_properties("ffmpeg_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;
ui->simpleOutPreset->addItem(QT_UTF8(name), val);
}
obs_properties_destroy(props);
defaultPreset = "default";
preset = curNVENCPreset;
} else { } else {
ui->simpleOutPreset->addItem("ultrafast", "ultrafast"); ui->simpleOutPreset->addItem("ultrafast", "ultrafast");
ui->simpleOutPreset->addItem("superfast", "superfast"); ui->simpleOutPreset->addItem("superfast", "superfast");

View File

@ -110,6 +110,7 @@ private:
QString curPreset; QString curPreset;
QString curQSVPreset; QString curQSVPreset;
QString curNVENCPreset;
using AudioSource_t = using AudioSource_t =
std::tuple<OBSWeakSource, std::tuple<OBSWeakSource,