UI: Fix screenshots preventing auto-remux

Due to the fact that a global was used on GenerateSpecifiedFilename to
save the remux file name, when a screenshot was made, it would overwrite
the filename being remuxed, because screenshots use the same function to
generate filenames as well.

This solves that problem by removing the global and the changes to
GeneratedSpecifiedFilename, and isolating that to the output handler.

Coincidentally, this bug probably also happened with replay buffers
under certain circumstances.

Fixes obsproject/obs-studio#3497
Closes obsproject/obs-studio#3498
This commit is contained in:
jp9000 2020-09-26 08:19:27 -07:00
commit e5d8f345fc
5 changed files with 43 additions and 48 deletions

View file

@ -948,9 +948,10 @@ bool SimpleOutput::ConfigureRecording(bool updateReplayBuffer)
usingRecordingPreset ? rbSize : 0);
} else {
f = GetFormatString(filenameFormat, nullptr, nullptr);
strPath = GetOutputFilename(path, ffmpegOutput ? "avi" : format,
noSpace, overwriteIfExists,
f.c_str());
strPath = GetRecordingFilename(path,
ffmpegOutput ? "avi" : format,
noSpace, overwriteIfExists,
f.c_str(), ffmpegOutput);
obs_data_set_string(settings, ffmpegOutput ? "url" : "path",
strPath.c_str());
}
@ -1701,9 +1702,10 @@ bool AdvancedOutput::StartRecording()
? "FFFileNameWithoutSpace"
: "RecFileNameWithoutSpace");
string strPath = GetOutputFilename(path, recFormat, noSpace,
overwriteIfExists,
filenameFormat);
string strPath = GetRecordingFilename(path, recFormat, noSpace,
overwriteIfExists,
filenameFormat,
ffmpegRecording);
obs_data_t *settings = obs_data_create();
obs_data_set_string(settings, ffmpegRecording ? "url" : "path",
@ -1846,6 +1848,25 @@ bool AdvancedOutput::ReplayBufferActive() const
/* ------------------------------------------------------------------------ */
bool BasicOutputHandler::SetupAutoRemux(const char *&ext)
{
bool autoRemux = config_get_bool(main->Config(), "Video", "AutoRemux");
if (autoRemux && strcmp(ext, "mp4") == 0)
ext = "mkv";
return autoRemux;
}
std::string
BasicOutputHandler::GetRecordingFilename(const char *path, const char *ext,
bool noSpace, bool overwrite,
const char *format, bool ffmpeg)
{
bool remux = !ffmpeg && SetupAutoRemux(ext);
string dst = GetOutputFilename(path, ext, noSpace, overwrite, format);
lastRecordingPath = remux ? dst : "";
return dst;
}
BasicOutputHandler *CreateSimpleOutputHandler(OBSBasic *main)
{
return new SimpleOutput(main);