Skip to content

Commit

Permalink
UI: Add Hybrid MP4 to format selection
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod committed May 26, 2024
1 parent 697fe39 commit fa3bca0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions UI/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ Basic.Settings.Output.Format.MP4="MPEG-4 (.mp4)"
Basic.Settings.Output.Format.MOV="QuickTime (.mov)"
Basic.Settings.Output.Format.TS="MPEG-TS (.ts)"
Basic.Settings.Output.Format.HLS="HLS (.m3u8 + .ts)"
Basic.Settings.Output.Format.hMP4="Hybrid MP4 [BETA] (.mp4)"
Basic.Settings.Output.Format.fMP4="Fragmented MP4 (.mp4)"
Basic.Settings.Output.Format.fMOV="Fragmented MOV (.mov)"
Basic.Settings.Output.Format.TT.fragmented_mov="Fragmented MOV writes the recording in chunks and does not require the same finalization as traditional MOV files.\nThis ensures the file remains playable even if writing to disk is interrupted, for example, as a result of a BSOD or power loss.\n\nThis may not be compatible with all players and editors. Use File → Remux Recordings to convert the file into a more compatible format if necessary."
Expand Down
14 changes: 14 additions & 0 deletions UI/ffmpeg-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ static const unordered_map<string, unordered_set<string>> codec_compat = {
"pcm_f32le",
#endif
}},
// Not part of FFmpeg, see obs-outputs module
{"hybrid_mp4",
{
"h264",
"hevc",
"av1",
"aac",
"opus",
"alac",
"flac",
"pcm_s16le",
"pcm_s24le",
"pcm_f32le",
}},
{"mov",
{
"h264",
Expand Down
2 changes: 2 additions & 0 deletions UI/obs-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,8 @@ string GetFormatExt(const char *container)
string ext = container;
if (ext == "fragmented_mp4")
ext = "mp4";
if (ext == "hybrid_mp4")
ext = "mp4";
else if (ext == "fragmented_mov")
ext = "mov";
else if (ext == "hls")
Expand Down
13 changes: 11 additions & 2 deletions UI/window-basic-main-outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
if (!ffmpegOutput) {
bool useReplayBuffer = config_get_bool(main->Config(),
"SimpleOutput", "RecRB");
const char *recFormat = config_get_string(
main->Config(), "SimpleOutput", "RecFormat2");

if (useReplayBuffer) {
OBSDataAutoRelease hotkey;
const char *str = config_get_string(
Expand Down Expand Up @@ -728,8 +731,10 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
OBSReplayBufferSaved, this);
}

bool use_native = strcmp(recFormat, "hybrid_mp4") == 0;
fileOutput = obs_output_create(
"ffmpeg_muxer", "simple_file_output", nullptr, nullptr);
use_native ? "mp4_output" : "ffmpeg_muxer",
"simple_file_output", nullptr, nullptr);
if (!fileOutput)
throw "Failed to create recording output "
"(simple output)";
Expand Down Expand Up @@ -1568,6 +1573,8 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
config_get_string(main->Config(), "AdvOut", "RecEncoder");
const char *recAudioEncoder =
config_get_string(main->Config(), "AdvOut", "RecAudioEncoder");
const char *recFormat =
config_get_string(main->Config(), "AdvOut", "RecFormat2");
#ifdef __APPLE__
translate_macvth264_encoder(streamEncoder);
translate_macvth264_encoder(recordEncoder);
Expand Down Expand Up @@ -1623,8 +1630,10 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
OBSReplayBufferSaved, this);
}

bool native_muxer = strcmp(recFormat, "hybrid_mp4") == 0;
fileOutput = obs_output_create(
"ffmpeg_muxer", "adv_file_output", nullptr, nullptr);
native_muxer ? "mp4_output" : "ffmpeg_muxer",
"adv_file_output", nullptr, nullptr);
if (!fileOutput)
throw "Failed to create recording output "
"(advanced output)";
Expand Down
2 changes: 2 additions & 0 deletions UI/window-basic-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ void OBSBasicSettings::LoadFormats()
ui->simpleOutRecFormat->addItem(FORMAT_STR("MKV"), "mkv");
ui->simpleOutRecFormat->addItem(FORMAT_STR("MP4"), "mp4");
ui->simpleOutRecFormat->addItem(FORMAT_STR("MOV"), "mov");
ui->simpleOutRecFormat->addItem(FORMAT_STR("hMP4"), "hybrid_mp4");
ui->simpleOutRecFormat->addItem(FORMAT_STR("fMP4"), "fragmented_mp4");
ui->simpleOutRecFormat->addItem(FORMAT_STR("fMOV"), "fragmented_mov");
ui->simpleOutRecFormat->addItem(FORMAT_STR("TS"), "mpegts");
Expand All @@ -1160,6 +1161,7 @@ void OBSBasicSettings::LoadFormats()
ui->advOutRecFormat->addItem(FORMAT_STR("MKV"), "mkv");
ui->advOutRecFormat->addItem(FORMAT_STR("MP4"), "mp4");
ui->advOutRecFormat->addItem(FORMAT_STR("MOV"), "mov");
ui->advOutRecFormat->addItem(FORMAT_STR("hMP4"), "hybrid_mp4");
ui->advOutRecFormat->addItem(FORMAT_STR("fMP4"), "fragmented_mp4");
ui->advOutRecFormat->addItem(FORMAT_STR("fMOV"), "fragmented_mov");
ui->advOutRecFormat->addItem(FORMAT_STR("TS"), "mpegts");
Expand Down

0 comments on commit fa3bca0

Please sign in to comment.