UI: Remux fragmented containers to regular counterparts

Also disables record-as-MKV when using fmp4.
This commit is contained in:
derrod 2023-03-29 07:11:35 +02:00 committed by Ryan Foster
parent 8e1cae4f02
commit 2560187611
3 changed files with 24 additions and 16 deletions

View file

@ -1336,7 +1336,8 @@ bool SimpleOutput::ConfigureRecording(bool updateReplayBuffer)
strPath = GetRecordingFilename(path,
ffmpegOutput ? "avi" : format,
noSpace, overwriteIfExists,
f.c_str(), ffmpegOutput);
f.c_str(), ffmpegOutput,
is_fragmented);
obs_data_set_string(settings, ffmpegOutput ? "url" : "path",
strPath.c_str());
if (ffmpegOutput)
@ -2187,6 +2188,7 @@ bool AdvancedOutput::StartRecording()
const char *recFormat;
const char *filenameFormat;
bool noSpace = false;
bool fragmented = false;
bool overwriteIfExists = false;
bool splitFile;
const char *splitFileType;
@ -2226,13 +2228,14 @@ bool AdvancedOutput::StartRecording()
// Strip leading "f" in case fragmented format was selected
if (strcmp(recFormat, "fmp4") == 0 ||
strcmp(recFormat, "fmov") == 0)
strcmp(recFormat, "fmov") == 0) {
++recFormat;
fragmented = true;
}
string strPath = GetRecordingFilename(path, recFormat, noSpace,
overwriteIfExists,
filenameFormat,
ffmpegRecording);
string strPath = GetRecordingFilename(
path, recFormat, noSpace, overwriteIfExists,
filenameFormat, ffmpegRecording, fragmented);
OBSDataAutoRelease settings = obs_data_create();
obs_data_set_string(settings, ffmpegRecording ? "url" : "path",
@ -2404,20 +2407,19 @@ bool AdvancedOutput::ReplayBufferActive() const
/* ------------------------------------------------------------------------ */
void BasicOutputHandler::SetupAutoRemux(const char *&ext)
void BasicOutputHandler::SetupAutoRemux(const char *&ext, bool is_fragmented)
{
bool autoRemux = config_get_bool(main->Config(), "Video", "AutoRemux");
if (autoRemux && strcmp(ext, "mp4") == 0)
if (autoRemux && !is_fragmented && strcmp(ext, "mp4") == 0)
ext = "mkv";
}
std::string
BasicOutputHandler::GetRecordingFilename(const char *path, const char *ext,
bool noSpace, bool overwrite,
const char *format, bool ffmpeg)
std::string BasicOutputHandler::GetRecordingFilename(
const char *path, const char *ext, bool noSpace, bool overwrite,
const char *format, bool ffmpeg, bool is_fragmented)
{
if (!ffmpeg)
SetupAutoRemux(ext);
SetupAutoRemux(ext, is_fragmented);
string dst = GetOutputFilename(path, ext, noSpace, overwrite, format);
lastRecordingPath = dst;

View file

@ -72,10 +72,11 @@ struct BasicOutputHandler {
}
protected:
void SetupAutoRemux(const char *&ext);
void SetupAutoRemux(const char *&ext, bool is_fragmented);
std::string GetRecordingFilename(const char *path, const char *ext,
bool noSpace, bool overwrite,
const char *format, bool ffmpeg);
const char *format, bool ffmpeg,
bool is_fragmented);
};
BasicOutputHandler *CreateSimpleOutputHandler(OBSBasic *main);

View file

@ -7401,8 +7401,13 @@ void OBSBasic::AutoRemux(QString input, bool no_show)
const obs_encoder_t *videoEncoder =
obs_output_get_video_encoder(outputHandler->fileOutput);
const char *codecName = obs_encoder_get_codec(videoEncoder);
string format = config_get_string(
config, isSimpleMode ? "SimpleOutput" : "AdvOut", "RecFormat2");
if (strcmp(codecName, "prores") == 0) {
/* Retain original container for fMP4/fMOV */
if (format == "fmp4" || format == "fmov") {
output += "remuxed." + suffix;
} else if (strcmp(codecName, "prores") == 0) {
output += "mov";
} else {
output += "mp4";