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:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user