[Ffmpeg-devel] [PATCH] MXF unplayable file

Reimar Döffinger Reimar.Doeffinger
Tue Aug 1 19:53:03 CEST 2006


Hello,
I have a MXF file that currently is unplayable.
The attached patch fixes two problems:
1) the mxf file contains an UMID tag with size 0. No idea if this really
is valid, but an extra check can't really hurt IMO
2) it doesn't have a picture essence codec tag, which according to the
spec is fine, since it's only a D/Req (decoder requirement). So the
attached patch falls back to selecting the codec ID via the mandatory
essence container tag. I do not know if these tags are officially
registered or what they really stand for.

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/mxf.c
===================================================================
--- libavformat/mxf.c	(revision 5880)
+++ libavformat/mxf.c	(working copy)
@@ -315,7 +315,11 @@
             break;
         case 0x1101:
             /* UMID, only get last 16 bytes */
-            url_fskip(pb, 16);
+            if (size < 16) {
+                url_fskip(pb, size);
+                break;
+            }
+            url_fskip(pb, size - 16);
             get_buffer(pb, source_clip->source_package_uid, 16);
             break;
         case 0x1102:
@@ -695,8 +699,15 @@
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 },        CODEC_ID_AC3 },
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 },        CODEC_ID_MP2 }, /* MP2 or MP3 */
   //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 },    CODEC_ID_DOLBY_E }, /* Dolby-E */
+    { { 0 }, CODEC_ID_NONE }
 };
 
+static const MXFCodecUL mxf_container_codec_uls[] = {
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, CODEC_ID_MPEG2VIDEO },
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, CODEC_ID_PCM_S24LE },
+    { { 0 }, CODEC_ID_NONE }
+};
+
 static enum CodecID mxf_get_codec_id(const MXFCodecUL *uls, UID *uid)
 {
     while (uls->id != CODEC_ID_NONE) {
@@ -800,8 +811,11 @@
         }
 #ifdef DEBUG
         PRINT_KEY(descriptor->essence_codec_ul);
+        PRINT_KEY(descriptor->essence_container_ul);
 #endif
         st->codec->codec_id = mxf_get_codec_id(mxf_codec_uls, &descriptor->essence_codec_ul);
+        if (st->codec->codec_id == CODEC_ID_NONE)
+            st->codec->codec_id = mxf_get_codec_id(mxf_container_codec_uls, &descriptor->essence_container_ul);
         if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
             st->codec->width = descriptor->width;
             st->codec->height = descriptor->height;



More information about the ffmpeg-devel mailing list