Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion frontend/forms/OBSBasicSettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -5818,7 +5818,7 @@
<number>20</number>
</property>
<property name="maximum">
<number>8192</number>
<number>8388608</number>
</property>
<property name="value">
<number>512</number>
Expand All @@ -5839,6 +5839,27 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="advRBStorageModeLabel">
<property name="text">
<string>Storage Mode (RAM / Disk)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="advRBStorageMode">
<item>
<property name="text">
<string>RAM (Memory)</string>
</property>
</item>
<item>
<property name="text">
<string>SSD/HDD (Disk)</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
18 changes: 15 additions & 3 deletions frontend/settings/OBSBasicSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->advOutTrack6Name, EDIT_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->advReplayBuf, CHECK_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->advRBSecMax, SCROLL_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->advRBStorageMode, COMBO_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->advRBMegsMax, SCROLL_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->channelSetup, COMBO_CHANGED, AUDIO_RESTART);
HookWidget(ui->sampleRate, COMBO_CHANGED, AUDIO_RESTART);
Expand Down Expand Up @@ -805,6 +806,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
connect(ui->advOutRecType, &QComboBox::currentIndexChanged, this, &OBSBasicSettings::AdvReplayBufferChanged);
connect(ui->advOutRecEncoder, &QComboBox::currentIndexChanged, this, &OBSBasicSettings::AdvReplayBufferChanged);
connect(ui->advRBSecMax, &QSpinBox::valueChanged, this, &OBSBasicSettings::AdvReplayBufferChanged);
connect(ui->advRBStorageMode, &QComboBox::currentIndexChanged, this, &OBSBasicSettings::AdvReplayBufferChanged);

// GPU scaling filters
auto addScaleFilter = [&](const char *string, int value) -> void {
Expand Down Expand Up @@ -2615,6 +2617,7 @@ void OBSBasicSettings::LoadAdvancedSettings()
bool replayBuf = config_get_bool(main->Config(), "AdvOut", "RecRB");
int rbTime = config_get_int(main->Config(), "AdvOut", "RecRBTime");
int rbSize = config_get_int(main->Config(), "AdvOut", "RecRBSize");
int rbStorageMode = config_get_int(main->Config(), "AdvOut", "RecRBStorageMode");
bool autoRemux = config_get_bool(main->Config(), "Video", "AutoRemux");
const char *hotkeyFocusType = config_get_string(App()->GetUserConfig(), "General", "HotkeyFocusType");
bool dynBitrate = config_get_bool(main->Config(), "Output", "DynamicBitrate");
Expand All @@ -2639,6 +2642,7 @@ void OBSBasicSettings::LoadAdvancedSettings()
ui->advReplayBuf->setChecked(replayBuf);
ui->advRBSecMax->setValue(rbTime);
ui->advRBMegsMax->setValue(rbSize);
ui->advRBStorageMode->setCurrentIndex(rbStorageMode);

ui->reconnectEnable->setChecked(reconnect);
ui->reconnectRetryDelay->setValue(retryDelay);
Expand Down Expand Up @@ -3602,6 +3606,9 @@ void OBSBasicSettings::SaveOutputSettings()
SaveCheckBox(ui->advReplayBuf, "AdvOut", "RecRB");
SaveSpinBox(ui->advRBSecMax, "AdvOut", "RecRBTime");
SaveSpinBox(ui->advRBMegsMax, "AdvOut", "RecRBSize");
if (WidgetChanged(ui->advRBStorageMode)) {
config_set_int(main->Config(), "AdvOut", "RecRBStorageMode", ui->advRBStorageMode->currentIndex());
}

WriteJsonData(streamEncoderProps, "streamEncoder.json");
WriteJsonData(recordEncoderProps, "recordEncoder.json");
Expand Down Expand Up @@ -5298,9 +5305,14 @@ void OBSBasicSettings::AdvReplayBufferChanged()

int seconds = ui->advRBSecMax->value();

// Set maximum to 75% of installed memory
uint64_t memTotal = os_get_sys_total_size();
int64_t memMaxMB = memTotal ? memTotal * 3 / 4 / 1024 / 1024 : 8192;
int64_t memMaxMB;
if (ui->advRBStorageMode->currentIndex() == 1) {
memMaxMB = 8388608; // 8TB limit for Disk
} else {
// Set maximum to 75% of installed memory for RAM
uint64_t memTotal = os_get_sys_total_size();
memMaxMB = memTotal ? memTotal * 3 / 4 / 1024 / 1024 : 8192;
}

int64_t memMB = int64_t(seconds) * int64_t(vbitrate + abitrate) * 1000 / 8 / 1024 / 1024;
if (memMB < 1) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/utility/AdvancedOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ bool AdvancedOutput::StartReplayBuffer()
rbSuffix = config_get_string(main->Config(), "SimpleOutput", "RecRBSuffix");
rbTime = config_get_int(main->Config(), "AdvOut", "RecRBTime");
rbSize = config_get_int(main->Config(), "AdvOut", "RecRBSize");
int rbStorageMode = config_get_int(main->Config(), "AdvOut", "RecRBStorageMode");

string f = GetFormatString(filenameFormat, rbPrefix, rbSuffix);
string ext = GetFormatExt(recFormat);
Expand All @@ -918,6 +919,7 @@ bool AdvancedOutput::StartReplayBuffer()
obs_data_set_bool(settings, "allow_spaces", !noSpace);
obs_data_set_int(settings, "max_time_sec", rbTime);
obs_data_set_int(settings, "max_size_mb", usesBitrate ? 0 : rbSize);
obs_data_set_int(settings, "storage_mode", rbStorageMode);

obs_output_update(replayBuffer, settings);
}
Expand Down
Loading