From eef63cd1886b174c232be2f36c8e0c78c9b829b5 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Mon, 20 Mar 2023 08:36:03 +0100 Subject: [PATCH] UI: Enforce stream audio to Opus if service is FTL --- UI/window-basic-main.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index fc0a62d99..4e81e78a0 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -1336,7 +1336,25 @@ bool OBSBasic::LoadService() hotkey_data); obs_service_release(service); - return !!service; + if (!service) + return false; + + /* Enforce Opus on FTL if needed */ + if (strcmp(obs_service_get_protocol(service), "FTL") == 0) { + const char *option = config_get_string( + basicConfig, "SimpleOutput", "StreamAudioEncoder"); + if (strcmp(option, "opus") != 0) + config_set_string(basicConfig, "SimpleOutput", + "StreamAudioEncoder", "opus"); + + option = config_get_string(basicConfig, "AdvOut", + "AudioEncoder"); + if (strcmp(obs_get_encoder_codec(option), "opus") != 0) + config_set_string(basicConfig, "AdvOut", "AudioEncoder", + "ffmpeg_opus"); + } + + return true; } bool OBSBasic::InitService()