From fc6d53763a2f81f94434f4deaf9dad512762726e Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 14 Nov 2020 08:05:52 -0800 Subject: [PATCH] UI: Add Twitch VOD track to simple output mode Allows the ability to use the separated Twitch VOD track with simple output mode in addition to advanced output mode. --- UI/data/locale/en-US.ini | 1 + UI/forms/OBSBasicSettings.ui | 10 ++++----- UI/window-basic-main-outputs.cpp | 32 +++++++++++++++++++++++++++ UI/window-basic-settings-stream.cpp | 34 ++++++++++++++++++++++++++--- UI/window-basic-settings.cpp | 1 + UI/window-basic-settings.hpp | 2 ++ 6 files changed, 72 insertions(+), 8 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 3f4a6b223..4c445023e 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -753,6 +753,7 @@ Basic.Settings.Output.Simple.Encoder.Hardware.QSV="Hardware (QSV)" Basic.Settings.Output.Simple.Encoder.Hardware.AMD="Hardware (AMD)" Basic.Settings.Output.Simple.Encoder.Hardware.NVENC="Hardware (NVENC)" Basic.Settings.Output.Simple.Encoder.SoftwareLowCPU="Software (x264 low CPU usage preset, increases file size)" +Basic.Settings.Output.Simple.TwitchVodTrack="Twitch VOD Track (Uses Track 2)" Basic.Settings.Output.Warn.EnforceResolutionFPS.Title="Incompatible Resolution/Framerate" Basic.Settings.Output.Warn.EnforceResolutionFPS.Msg="This streaming service does not support your current output resolution and/or framerate. They will be changed to the closest compatible value:\n\n%1\n\nDo you want to continue?" Basic.Settings.Output.Warn.EnforceResolutionFPS.Resolution="Resolution: %1" diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index d48cd69f9..27e29ebb5 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -1295,8 +1295,8 @@ 0 0 - 601 - 602 + 820 + 677 @@ -1402,7 +1402,7 @@ Basic.Settings.Output.Adv.Streaming - + QFormLayout::AllNonFixedFieldsGrow @@ -4592,8 +4592,8 @@ 0 0 - 818 - 675 + 98 + 28 diff --git a/UI/window-basic-main-outputs.cpp b/UI/window-basic-main-outputs.cpp index 42fdbecbe..9d60d7335 100644 --- a/UI/window-basic-main-outputs.cpp +++ b/UI/window-basic-main-outputs.cpp @@ -249,10 +249,12 @@ struct SimpleOutput : BasicOutputHandler { OBSEncoder aacStreaming; OBSEncoder h264Streaming; OBSEncoder aacRecording; + OBSEncoder aacArchive; OBSEncoder h264Recording; string aacRecEncID; string aacStreamEncID; + string aacArchiveEncID; string videoEncoder; string videoQuality; @@ -286,6 +288,8 @@ struct SimpleOutput : BasicOutputHandler { void UpdateRecording(); bool ConfigureRecording(bool useReplayBuffer); + void SetupVodTrack(obs_service_t *service); + virtual bool SetupStreaming(obs_service_t *service) override; virtual bool StartStreaming(obs_service_t *service) override; virtual bool StartRecording() override; @@ -409,6 +413,9 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_) if (!CreateAACEncoder(aacStreaming, aacStreamEncID, GetAudioBitrate(), "simple_aac", 0)) throw "Failed to create aac streaming encoder (simple output)"; + if (!CreateAACEncoder(aacArchive, aacArchiveEncID, GetAudioBitrate(), + "archive_aac", 1)) + throw "Failed to create aac arhive encoder (simple output)"; LoadRecordingPreset(); @@ -535,6 +542,7 @@ void SimpleOutput::Update() obs_encoder_update(h264Streaming, h264Settings); obs_encoder_update(aacStreaming, aacSettings); + obs_encoder_update(aacArchive, aacSettings); obs_data_release(h264Settings); obs_data_release(aacSettings); @@ -709,6 +717,7 @@ inline void SimpleOutput::SetupOutputs() SimpleOutput::Update(); obs_encoder_set_video(h264Streaming, obs_get_video()); obs_encoder_set_audio(aacStreaming, obs_get_audio()); + obs_encoder_set_audio(aacArchive, obs_get_audio()); if (usingRecordingPreset) { if (ffmpegOutput) { @@ -833,6 +842,27 @@ bool SimpleOutput::SetupStreaming(obs_service_t *service) return true; } +static inline bool ServiceSupportsVodTrack(const char *service); + +void SimpleOutput::SetupVodTrack(obs_service_t *service) +{ + bool advanced = + config_get_bool(main->Config(), "SimpleOutput", "UseAdvanced"); + bool enable = config_get_bool(main->Config(), "SimpleOutput", + "VodTrackEnabled"); + + obs_data_t *settings = obs_service_get_settings(service); + const char *name = obs_data_get_string(settings, "service"); + + if (advanced && enable && ServiceSupportsVodTrack(name)) { + obs_output_set_audio_encoder(streamOutput, aacArchive, 1); + } else { + obs_output_set_audio_encoder(streamOutput, nullptr, 1); + } + + obs_data_release(settings); +} + bool SimpleOutput::StartStreaming(obs_service_t *service) { bool reconnect = config_get_bool(main->Config(), "Output", "Reconnect"); @@ -872,6 +902,8 @@ bool SimpleOutput::StartStreaming(obs_service_t *service) obs_output_set_reconnect_settings(streamOutput, maxRetries, retryDelay); + SetupVodTrack(service); + if (obs_output_start(streamOutput)) { return true; } diff --git a/UI/window-basic-settings-stream.cpp b/UI/window-basic-settings-stream.cpp index 22c616c00..133d9351c 100644 --- a/UI/window-basic-settings-stream.cpp +++ b/UI/window-basic-settings-stream.cpp @@ -628,14 +628,42 @@ void OBSBasicSettings::UpdateVodTrackSetting() if (!enableVodTrack) { delete vodTrackCheckbox; delete vodTrackContainer; + delete simpleVodTrack; return; } - vodTrackCheckbox = new QCheckBox( + /* -------------------------------------- */ + /* simple output mode vod track widgets */ + + bool simpleAdv = ui->simpleOutAdvanced->isChecked(); + bool vodTrackEnabled = config_get_bool(main->Config(), "SimpleOutput", + "VodTrackEnabled"); + + simpleVodTrack = new QCheckBox(this); + simpleVodTrack->setText( + QTStr("Basic.Settings.Output.Simple.TwitchVodTrack")); + simpleVodTrack->setVisible(simpleAdv); + simpleVodTrack->setChecked(vodTrackEnabled); + + int pos; + ui->simpleStreamingLayout->getWidgetPosition(ui->simpleOutAdvanced, + &pos, nullptr); + ui->simpleStreamingLayout->insertRow(pos + 1, nullptr, simpleVodTrack); + + HookWidget(simpleVodTrack, SIGNAL(clicked(bool)), + SLOT(OutputsChanged())); + connect(ui->simpleOutAdvanced, SIGNAL(toggled(bool)), + simpleVodTrack.data(), SLOT(setVisible(bool))); + + /* -------------------------------------- */ + /* advanced output mode vod track widgets */ + + vodTrackCheckbox = new QCheckBox(this); + vodTrackCheckbox->setText( QTStr("Basic.Settings.Output.Adv.TwitchVodTrack")); vodTrackCheckbox->setLayoutDirection(Qt::RightToLeft); - vodTrackContainer = new QWidget(); + vodTrackContainer = new QWidget(this); QHBoxLayout *vodTrackLayout = new QHBoxLayout(); for (int i = 0; i < MAX_AUDIO_MIXES; i++) { vodTrack[i] = new QRadioButton(QString::number(i + 1)); @@ -655,7 +683,7 @@ void OBSBasicSettings::UpdateVodTrackSetting() ui->advOutTopLayout->insertRow(2, vodTrackCheckbox, vodTrackContainer); - bool vodTrackEnabled = + vodTrackEnabled = config_get_bool(main->Config(), "AdvOut", "VodTrackEnabled"); vodTrackCheckbox->setChecked(vodTrackEnabled); vodTrackContainer->setEnabled(vodTrackEnabled); diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 7450c96b2..fd081ce10 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -3403,6 +3403,7 @@ void OBSBasicSettings::SaveOutputSettings() SaveEdit(ui->advOutTrack6Name, "AdvOut", "Track6Name"); if (vodTrackCheckbox) { + SaveCheckBox(simpleVodTrack, "SimpleOutput", "VodTrackEnabled"); SaveCheckBox(vodTrackCheckbox, "AdvOut", "VodTrackEnabled"); SaveTrackIndex(main->Config(), "AdvOut", "VodTrackIndex", vodTrack[0], vodTrack[1], vodTrack[2], diff --git a/UI/window-basic-settings.hpp b/UI/window-basic-settings.hpp index 1387a2046..4b5d352f2 100644 --- a/UI/window-basic-settings.hpp +++ b/UI/window-basic-settings.hpp @@ -159,6 +159,8 @@ private: uint32_t outputCX = 0; uint32_t outputCY = 0; + QPointer simpleVodTrack; + QPointer vodTrackCheckbox; QPointer vodTrackContainer; QPointer vodTrack[MAX_AUDIO_MIXES];