obs-ffmpeg: Update NVENC properties and property defaults

Adds VBR rate control mode, adds a lookahead option, adds psycho visual
tuning option, removes level property (now always set to 'auto'),
removes "2pass" option (replaced by new "Max Quality" preset which uses
2pass by default), modifies a few defaults, and updates their locale
text.
master
jp9000 2019-02-05 18:16:43 -08:00
parent 9c11772682
commit 8b566f3352
2 changed files with 42 additions and 55 deletions

View File

@ -2,22 +2,25 @@ FFmpegOutput="FFmpeg Output"
FFmpegAAC="FFmpeg Default AAC Encoder"
FFmpegOpus="FFmpeg Opus Encoder"
Bitrate="Bitrate"
MaxBitrate="Max Bitrate"
Preset="Preset"
RateControl="Rate Control"
KeyframeIntervalSec="Keyframe Interval (seconds, 0=auto)"
Lossless="Lossless"
BFrames="B-frames"
BFrames="Max B-frames"
NVENC.Use2Pass="Use Two-Pass Encoding"
NVENC.Preset.default="Default"
NVENC.Preset.hq="High Quality"
NVENC.Preset.hp="High Performance"
NVENC.Preset.bd="Bluray"
NVENC.Preset.default="Performance"
NVENC.Preset.hq="Quality"
NVENC.Preset.hp="Max Performance"
NVENC.Preset.mq="Max Quality"
NVENC.Preset.ll="Low-Latency"
NVENC.Preset.llhq="Low-Latency High Quality"
NVENC.Preset.llhp="Low-Latency High Performance"
NVENC.Level="Level"
NVENC.Preset.llhq="Low-Latency Quality"
NVENC.Preset.llhp="Low-Latency Performance"
NVENC.LookAhead="Look-ahead"
NVENC.PsychoVisualTuning="Psycho Visual Tuning"
NVENC.CQLevel="CQ Level"
FFmpegSource="Media Source"
LocalFile="Local File"

View File

@ -134,8 +134,6 @@ static bool nvenc_update(void *data, obs_data_t *settings)
int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
const char *preset = obs_data_get_string(settings, "preset");
const char *profile = obs_data_get_string(settings, "profile");
const char *level = obs_data_get_string(settings, "level");
bool twopass = obs_data_get_bool(settings, "2pass");
int gpu = (int)obs_data_get_int(settings, "gpu");
bool cbr_override = obs_data_get_bool(settings, "cbr");
int bf = (int)obs_data_get_int(settings, "bf");
@ -158,6 +156,13 @@ static bool nvenc_update(void *data, obs_data_t *settings)
info.colorspace = voi->colorspace;
info.range = voi->range;
bool twopass = false;
if (astrcmpi(preset, "mq") == 0) {
twopass = true;
preset = "hq";
}
nvenc_video_info(enc, &info);
av_opt_set_int(enc->context->priv_data, "cbr", false, 0);
av_opt_set(enc->context->priv_data, "profile", profile, 0);
@ -185,7 +190,7 @@ static bool nvenc_update(void *data, obs_data_t *settings)
}
av_opt_set(enc->context->priv_data, "level", level, 0);
av_opt_set(enc->context->priv_data, "level", "auto", 0);
av_opt_set_int(enc->context->priv_data, "2pass", twopass, 0);
av_opt_set_int(enc->context->priv_data, "gpu", gpu, 0);
@ -216,14 +221,13 @@ static bool nvenc_update(void *data, obs_data_t *settings)
"\tkeyint: %d\n"
"\tpreset: %s\n"
"\tprofile: %s\n"
"\tlevel: %s\n"
"\twidth: %d\n"
"\theight: %d\n"
"\t2-pass: %s\n"
"\tb-frames: %d\n"
"\tGPU: %d\n",
rc, bitrate, cqp, enc->context->gop_size,
preset, profile, level,
preset, profile,
enc->context->width, enc->context->height,
twopass ? "true" : "false",
enc->context->max_b_frames,
@ -390,16 +394,16 @@ static bool nvenc_encode(void *data, struct encoder_frame *frame,
return true;
}
static void nvenc_defaults(obs_data_t *settings)
void nvenc_defaults(obs_data_t *settings)
{
obs_data_set_default_int(settings, "bitrate", 2500);
obs_data_set_default_int(settings, "max_bitrate", 5000);
obs_data_set_default_int(settings, "keyint_sec", 0);
obs_data_set_default_int(settings, "cqp", 23);
obs_data_set_default_int(settings, "cqp", 20);
obs_data_set_default_string(settings, "rate_control", "CBR");
obs_data_set_default_string(settings, "preset", "default");
obs_data_set_default_string(settings, "profile", "main");
obs_data_set_default_string(settings, "level", "auto");
obs_data_set_default_bool(settings, "2pass", true);
obs_data_set_default_string(settings, "preset", "hq");
obs_data_set_default_string(settings, "profile", "high");
obs_data_set_default_bool(settings, "psycho_aq", true);
obs_data_set_default_int(settings, "gpu", 0);
obs_data_set_default_int(settings, "bf", 2);
}
@ -409,11 +413,14 @@ static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
{
const char *rc = obs_data_get_string(settings, "rate_control");
bool cqp = astrcmpi(rc, "CQP") == 0;
bool vbr = astrcmpi(rc, "VBR") == 0;
bool lossless = astrcmpi(rc, "lossless") == 0;
size_t count;
p = obs_properties_get(ppts, "bitrate");
obs_property_set_visible(p, !cqp && !lossless);
p = obs_properties_get(ppts, "max_bitrate");
obs_property_set_visible(p, vbr);
p = obs_properties_get(ppts, "cqp");
obs_property_set_visible(p, cqp);
@ -421,14 +428,14 @@ static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
count = obs_property_list_item_count(p);
for (size_t i = 0; i < count; i++) {
bool compatible = (i == 0 || i == 2);
bool compatible = (i == 0 || i == 3);
obs_property_list_item_disable(p, i, lossless && !compatible);
}
return true;
}
static obs_properties_t *nvenc_properties(void *unused)
obs_properties_t *nvenc_properties(void *unused)
{
UNUSED_PARAMETER(unused);
@ -439,8 +446,8 @@ static obs_properties_t *nvenc_properties(void *unused)
obs_module_text("RateControl"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
obs_property_list_add_string(p, "CBR", "CBR");
obs_property_list_add_string(p, "CQ", "CQP");
obs_property_list_add_string(p, "VBR", "VBR");
obs_property_list_add_string(p, "CQP", "CQP");
obs_property_list_add_string(p, obs_module_text("Lossless"),
"lossless");
@ -448,8 +455,11 @@ static obs_properties_t *nvenc_properties(void *unused)
obs_properties_add_int(props, "bitrate",
obs_module_text("Bitrate"), 50, 300000, 50);
obs_properties_add_int(props, "max_bitrate",
obs_module_text("MaxBitrate"), 50, 300000, 50);
obs_properties_add_int(props, "cqp", "CQP", 0, 50, 1);
obs_properties_add_int(props, "cqp", obs_module_text("NVENC.CQLevel"),
1, 30, 1);
obs_properties_add_int(props, "keyint_sec",
obs_module_text("KeyframeIntervalSec"), 0, 10, 1);
@ -460,10 +470,10 @@ static obs_properties_t *nvenc_properties(void *unused)
#define add_preset(val) \
obs_property_list_add_string(p, obs_module_text("NVENC.Preset." val), \
val)
add_preset("default");
add_preset("mq");
add_preset("hq");
add_preset("default");
add_preset("hp");
add_preset("bd");
add_preset("ll");
add_preset("llhq");
add_preset("llhp");
@ -477,38 +487,12 @@ static obs_properties_t *nvenc_properties(void *unused)
add_profile("high");
add_profile("main");
add_profile("baseline");
add_profile("high444p");
p = obs_properties_add_list(props, "level",
obs_module_text("NVENC.Level"), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
add_profile("auto");
add_profile("1" );
add_profile("1.0" );
add_profile("1b" );
add_profile("1.0b");
add_profile("1.1" );
add_profile("1.2" );
add_profile("1.3" );
add_profile("2" );
add_profile("2.0" );
add_profile("2.1" );
add_profile("2.2" );
add_profile("3" );
add_profile("3.0" );
add_profile("3.1" );
add_profile("3.2" );
add_profile("4" );
add_profile("4.0" );
add_profile("4.1" );
add_profile("4.2" );
add_profile("5" );
add_profile("5.0" );
add_profile("5.1" );
#undef add_profile
obs_properties_add_bool(props, "2pass",
obs_module_text("NVENC.Use2Pass"));
obs_properties_add_bool(props, "lookahead",
obs_module_text("NVENC.LookAhead"));
obs_properties_add_bool(props, "psycho_aq",
obs_module_text("NVENC.PsychoVisualTuning"));
obs_properties_add_int(props, "gpu", obs_module_text("GPU"), 0, 8, 1);
obs_properties_add_int(props, "bf", obs_module_text("BFrames"),