mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 17:49:14 +00:00
UI: Add simple output mode encoder fallback
Prevents simple output mode from getting stuck on an encoder that may not be available suddenly for whatever reason (system device changes, driver issues, etc). If the encoder is no longer available, falls back to x264 to ensure that the user can continue to use the program.
This commit is contained in:
parent
f09f94b8a8
commit
bd0983a89e
|
@ -597,6 +597,8 @@ void OBSBasic::ChangeProfile()
|
|||
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
|
||||
UpdateTitleBar();
|
||||
|
||||
CheckForSimpleModeX264Fallback();
|
||||
|
||||
blog(LOG_INFO, "Switched to profile '%s' (%s)",
|
||||
newName, newDir);
|
||||
blog(LOG_INFO, "------------------------------------------------");
|
||||
|
@ -604,3 +606,62 @@ void OBSBasic::ChangeProfile()
|
|||
if (api)
|
||||
api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
|
||||
}
|
||||
|
||||
void OBSBasic::CheckForSimpleModeX264Fallback()
|
||||
{
|
||||
const char *curStreamEncoder = config_get_string(basicConfig,
|
||||
"SimpleOutput", "StreamEncoder");
|
||||
const char *curRecEncoder = config_get_string(basicConfig,
|
||||
"SimpleOutput", "RecEncoder");
|
||||
bool qsv_supported = false;
|
||||
bool amd_supported = false;
|
||||
bool nve_supported = false;
|
||||
bool changed = false;
|
||||
size_t idx = 0;
|
||||
const char *id;
|
||||
|
||||
while (obs_enum_encoder_types(idx++, &id)) {
|
||||
if (strcmp(id, "amd_amf_h264") == 0)
|
||||
amd_supported = true;
|
||||
else if (strcmp(id, "obs_qsv11") == 0)
|
||||
qsv_supported = true;
|
||||
else if (strcmp(id, "ffmpeg_nvenc") == 0)
|
||||
nve_supported = true;
|
||||
}
|
||||
|
||||
auto CheckEncoder = [&] (const char *&name)
|
||||
{
|
||||
if (strcmp(name, SIMPLE_ENCODER_QSV) == 0) {
|
||||
if (!qsv_supported) {
|
||||
changed = true;
|
||||
name = SIMPLE_ENCODER_X264;
|
||||
return false;
|
||||
}
|
||||
} else if (strcmp(name, SIMPLE_ENCODER_NVENC) == 0) {
|
||||
if (!nve_supported) {
|
||||
changed = true;
|
||||
name = SIMPLE_ENCODER_X264;
|
||||
return false;
|
||||
}
|
||||
} else if (strcmp(name, SIMPLE_ENCODER_AMD) == 0) {
|
||||
if (!amd_supported) {
|
||||
changed = true;
|
||||
name = SIMPLE_ENCODER_X264;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!CheckEncoder(curStreamEncoder))
|
||||
config_set_string(basicConfig,
|
||||
"SimpleOutput", "StreamEncoder",
|
||||
curStreamEncoder);
|
||||
if (!CheckEncoder(curRecEncoder))
|
||||
config_set_string(basicConfig,
|
||||
"SimpleOutput", "RecEncoder",
|
||||
curRecEncoder);
|
||||
if (changed)
|
||||
config_save_safe(basicConfig, "tmp", nullptr);
|
||||
}
|
||||
|
|
|
@ -1479,6 +1479,8 @@ void OBSBasic::OBSInit()
|
|||
blog(LOG_INFO, "---------------------------------");
|
||||
obs_post_load_modules();
|
||||
|
||||
CheckForSimpleModeX264Fallback();
|
||||
|
||||
blog(LOG_INFO, STARTUP_SEPARATOR);
|
||||
|
||||
ResetOutputs();
|
||||
|
|
|
@ -269,6 +269,7 @@ private:
|
|||
void DeleteProfile(const char *profile_name, const char *profile_dir);
|
||||
void RefreshProfiles();
|
||||
void ChangeProfile();
|
||||
void CheckForSimpleModeX264Fallback();
|
||||
|
||||
void SaveProjectNow();
|
||||
|
||||
|
|
Loading…
Reference in a new issue