From 38dfa553a2b9bd75cd7bcc209a4fc6165dcc0c4c Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 21 Aug 2005 13:04:48 +0000 Subject: [PATCH] Disallow putting AVC/h.264 video in VfW compatibility mode. Can be forced with a new --engage option. --- src/common/hacks.cpp | 1 + src/common/hacks.h | 1 + src/mmg/mmg.cpp | 3 +++ src/output/p_video.cpp | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/src/common/hacks.cpp b/src/common/hacks.cpp index 0a373ac37..5200aca1d 100644 --- a/src/common/hacks.cpp +++ b/src/common/hacks.cpp @@ -38,6 +38,7 @@ static const char *mosu_hacks[] = { ENGAGE_FORCE_PASSTHROUGH_PACKETIZER, ENGAGE_AVC_USE_BFRAMES, ENGAGE_WRITE_HEADERS_TWICE, + ENGAGE_ALLOW_AVC_IN_VFW_MODE, NULL }; static vector engaged_hacks; diff --git a/src/common/hacks.h b/src/common/hacks.h index 89f47a6fc..5dbe2b091 100644 --- a/src/common/hacks.h +++ b/src/common/hacks.h @@ -35,6 +35,7 @@ using namespace std; #define ENGAGE_FORCE_PASSTHROUGH_PACKETIZER "force_passthrough_packetizer" #define ENGAGE_AVC_USE_BFRAMES "avc_use_bframes" #define ENGAGE_WRITE_HEADERS_TWICE "write_headers_twice" +#define ENGAGE_ALLOW_AVC_IN_VFW_MODE "allow_avc_in_vfw_mode" void MTX_DLL_API engage_hacks(const string &hacks); bool MTX_DLL_API hack_engaged(const string &hack); diff --git a/src/mmg/mmg.cpp b/src/mmg/mmg.cpp index 2624ff938..d97685693 100644 --- a/src/mmg/mmg.cpp +++ b/src/mmg/mmg.cpp @@ -131,6 +131,9 @@ wxString cli_options[][2] = { { wxT("--engage force_passthrough_packetizer"), wxT("Forces the Matroska reader to use the generic passthrough " "packetizer even for known and supported track types.") }, + { wxT("--engage allow_avc_in_vfw_mode"), + wxT("Allows storing AVC/h.264 video in Video-for-Windows compatibility " + "mode, e.g. when it is read from an AVI") }, { wxT("--engage cow"), wxT("No help available.") }, { wxT(""), wxT("") } diff --git a/src/output/p_video.cpp b/src/output/p_video.cpp index 1959605d6..07b7b960c 100644 --- a/src/output/p_video.cpp +++ b/src/output/p_video.cpp @@ -66,6 +66,42 @@ video_packetizer_c::check_fourcc() { ti.fourcc, 4); set_codec_private(ti.private_data, ti.private_size); } + + if (!hack_engaged(ENGAGE_ALLOW_AVC_IN_VFW_MODE) && + (hcodec_id == MKV_V_MSCOMP) && + (ti.private_data != NULL) && + (ti.private_size >= sizeof(alBITMAPINFOHEADER))) { + const char *avc_fourccs[] = { + "h264", "x264", "avc1", NULL + }; + const char *fourcc; + int i; + + fourcc = (const char *) + &((alBITMAPINFOHEADER *)ti.private_data)->bi_compression; + for (i = 0; NULL != avc_fourccs[i]; ++i) + if (!strncasecmp(fourcc, avc_fourccs[i], 4)) + mxerror(FMT_TID "You are trying to put AVC/h.264 video from an AVI " + "or a similar VfW (Video for Windows) compatible source into " + "a Matroska file in the so-called 'VfW compatibility mode'. " + "Please note that this is not the official way to store " + "AVC/h.264 video in Matroska. Therefore proper playback of " + "such files cannot be guaranteed, and we strongly urge you " + "not to continue to do this.\n" + "At the moment mkvmerge does not support converting from " + "VfW-mode AVC/h.264 tracks to native Matroska-mode AVC/h.264 " + "tracks. You can, however, first import the video track " + "into a MP4 file with e.g. 'MP4Box' (use Google). Then " + "you can use mkvmerge and put the video into a Matroska " + "file.\n" + "If you really know what you are doing then you can force " + "mkvmerge to put this AVC/h.264 track into a Matroska file " + "even in VfW mode if you add '--engage allow_avc_in_vfw_mode' " + "to the command line. You can do that in mmg with the " + "'Add command line options' menu entry in the 'Muxing' " + "menu.\n", + ti.fname.c_str(), (int64_t)ti.id); + } } void