Disallow putting AVC/h.264 video in VfW compatibility mode. Can be forced with a new --engage option.

This commit is contained in:
Moritz Bunkus 2005-08-21 13:04:48 +00:00
parent f86057e18d
commit 38dfa553a2
4 changed files with 41 additions and 0 deletions

View File

@ -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<string> engaged_hacks;

View File

@ -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);

View File

@ -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("") }

View File

@ -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