提交 9fee8953 编写于 作者: J jp9000

UI: Use hardware encoding by default if available

If the user doesn't use the auto-configuration on first use, set the
default encoders used in simple output mode to hardware encoders.
上级 93ba6e71
......@@ -711,6 +711,17 @@ bool OBSApp::InitGlobalConfig()
changed = true;
}
if (!config_has_user_value(globalConfig, "General", "Pre23Defaults")) {
uint32_t lastVersion = config_get_int(globalConfig, "General",
"LastVersion");
bool useOldDefaults = lastVersion &&
lastVersion < MAKE_SEMANTIC_VERSION(23, 0, 0);
config_set_bool(globalConfig, "General", "Pre23Defaults",
useOldDefaults);
changed = true;
}
if (config_has_user_value(globalConfig, "BasicWindow",
"MultiviewLayout")) {
const char *layout = config_get_string(globalConfig,
......
......@@ -244,6 +244,7 @@ bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
config.SaveSafe("tmp");
config.Swap(basicConfig);
InitBasicConfigDefaults();
InitBasicConfigDefaults2();
RefreshProfiles();
if (create_new)
......@@ -464,6 +465,7 @@ void OBSBasic::on_actionRemoveProfile_triggered()
config.Swap(basicConfig);
InitBasicConfigDefaults();
InitBasicConfigDefaults2();
ResetProfileData();
DeleteProfile(oldName.c_str(), oldDir.c_str());
RefreshProfiles();
......@@ -627,6 +629,7 @@ void OBSBasic::ChangeProfile()
config.Swap(basicConfig);
InitBasicConfigDefaults();
InitBasicConfigDefaults2();
ResetProfileData();
RefreshProfiles();
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
......
......@@ -1185,8 +1185,6 @@ bool OBSBasic::InitBasicConfigDefaults()
"flv");
config_set_default_uint (basicConfig, "SimpleOutput", "VBitrate",
2500);
config_set_default_string(basicConfig, "SimpleOutput", "StreamEncoder",
SIMPLE_ENCODER_X264);
config_set_default_uint (basicConfig, "SimpleOutput", "ABitrate", 160);
config_set_default_bool (basicConfig, "SimpleOutput", "UseAdvanced",
false);
......@@ -1196,8 +1194,6 @@ bool OBSBasic::InitBasicConfigDefaults()
"veryfast");
config_set_default_string(basicConfig, "SimpleOutput", "RecQuality",
"Stream");
config_set_default_string(basicConfig, "SimpleOutput", "RecEncoder",
SIMPLE_ENCODER_X264);
config_set_default_bool(basicConfig, "SimpleOutput", "RecRB", false);
config_set_default_int(basicConfig, "SimpleOutput", "RecRBTime", 20);
config_set_default_int(basicConfig, "SimpleOutput", "RecRBSize", 512);
......@@ -1326,6 +1322,20 @@ bool OBSBasic::InitBasicConfigDefaults()
return true;
}
extern bool EncoderAvailable(const char *encoder);
void OBSBasic::InitBasicConfigDefaults2()
{
bool oldEncDefaults = config_get_bool(App()->GlobalConfig(),
"General", "Pre23Defaults");
bool useNV = EncoderAvailable("ffmpeg_nvenc") && !oldEncDefaults;
config_set_default_string(basicConfig, "SimpleOutput", "StreamEncoder",
useNV ? SIMPLE_ENCODER_NVENC : SIMPLE_ENCODER_X264);
config_set_default_string(basicConfig, "SimpleOutput", "RecEncoder",
useNV ? SIMPLE_ENCODER_NVENC : SIMPLE_ENCODER_X264);
}
bool OBSBasic::InitBasicConfig()
{
ProfileScope("OBSBasic::InitBasicConfig");
......@@ -1557,6 +1567,8 @@ void OBSBasic::OBSInit()
cef = obs_browser_init_panel();
#endif
InitBasicConfigDefaults2();
CheckForSimpleModeX264Fallback();
blog(LOG_INFO, STARTUP_SEPARATOR);
......
......@@ -254,6 +254,7 @@ private:
bool InitService();
bool InitBasicConfigDefaults();
void InitBasicConfigDefaults2();
bool InitBasicConfig();
void InitOBSCallbacks();
......
......@@ -3913,7 +3913,7 @@ void OBSBasicSettings::UpdateStreamDelayEstimate()
UpdateAutomaticReplayBufferCheckboxes();
}
static bool EncoderAvailable(const char *encoder)
bool EncoderAvailable(const char *encoder)
{
const char *val;
int i = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册