diff --git a/src/common/hacks.cpp b/src/common/hacks.cpp index 0993c808a..0a373ac37 100644 --- a/src/common/hacks.cpp +++ b/src/common/hacks.cpp @@ -37,6 +37,7 @@ static const char *mosu_hacks[] = { ENGAGE_NO_DEFAULT_HEADER_VALUES, ENGAGE_FORCE_PASSTHROUGH_PACKETIZER, ENGAGE_AVC_USE_BFRAMES, + ENGAGE_WRITE_HEADERS_TWICE, NULL }; static vector engaged_hacks; diff --git a/src/common/hacks.h b/src/common/hacks.h index bb99b9fe4..89f47a6fc 100644 --- a/src/common/hacks.h +++ b/src/common/hacks.h @@ -34,6 +34,7 @@ using namespace std; #define ENGAGE_NO_DEFAULT_HEADER_VALUES "no_default_header_values" #define ENGAGE_FORCE_PASSTHROUGH_PACKETIZER "force_passthrough_packetizer" #define ENGAGE_AVC_USE_BFRAMES "avc_use_bframes" +#define ENGAGE_WRITE_HEADERS_TWICE "write_headers_twice" void MTX_DLL_API engage_hacks(const string &hacks); bool MTX_DLL_API hack_engaged(const string &hack); diff --git a/src/merge/output_control.cpp b/src/merge/output_control.cpp index fd0c15bef..29fd70fa1 100644 --- a/src/merge/output_control.cpp +++ b/src/merge/output_control.cpp @@ -1441,6 +1441,14 @@ finish_file(bool last_file) { mxinfo("\n"); + // Render the track headers a second time if the user has requested that. + if (hack_engaged(ENGAGE_WRITE_HEADERS_TWICE)) { + EbmlElement *second_tracks = kax_tracks.Clone(); + second_tracks->Render(*out); + kax_sh_main->IndexThis(*second_tracks, *kax_segment); + delete second_tracks; + } + // Render the cues. if (write_cues && cue_writing_requested) { if (verbose >= 1) @@ -1503,6 +1511,12 @@ finish_file(bool last_file) { } out->restore_pos(); + // Render the segment info a second time if the user has requested that. + if (hack_engaged(ENGAGE_WRITE_HEADERS_TWICE)) { + kax_infos->Render(*out); + kax_sh_main->IndexThis(*kax_infos, *kax_segment); + } + // Select the chapters that lie in this file and render them in the space // that was resesrved at the beginning. if (kax_chapters != NULL) {