[FFmpeg-devel] MXF encoding: could not get mpeg2 profile and level

Christopher Fraser chrisf
Fri Nov 20 21:53:43 CET 2009


Hello,

I was trying to use fmmpeg to repackage some HDV mpeg transport streams 
as MXFs. Whenever I tried to repackage HDV streams I would get an error 
along the lines of:

[mxf @ 0x2f265d0]could not get mpeg2 profile and level

However, repackaging other MPEG2 files would sometimes mysteriously work.

I eventually tracked this down to mxf_get_mpeg2_codec_ul in 
libavformat/mxfenc.c. My HDV streams were being assigned a level of 6, 
which was not supported by the encoder so I made the following change:

--- libavformat/mxfenc.c.orig	2009-11-20 19:47:33.000000000 +0000
+++ libavformat/mxfenc.c	2009-11-20 19:47:07.000000000 +0000
@@ -1287,17 +1287,17 @@

  static const UID *mxf_get_mpeg2_codec_ul(AVCodecContext *avctx)
  {
      int long_gop = avctx->gop_size > 1 || avctx->has_b_frames;

      if (avctx->profile == 4) { // Main
          if (avctx->level == 8) // Main
              return &mxf_mpeg2_codec_uls[0+long_gop];
-        else if (avctx->level == 4) // High
+        else if (avctx->level < 8) // High
              return &mxf_mpeg2_codec_uls[4+long_gop];
      } else if (avctx->profile == 0) { // 422
          if (avctx->level == 5) // Main
              return &mxf_mpeg2_codec_uls[2+long_gop];
          else if (avctx->level == 2) // High
              return &mxf_mpeg2_codec_uls[6+long_gop];
      }
      return NULL;

I don't know enough about MXF or MPEG2 to know if this is a sensible 
change or not, but it certainly allows me to repackage my streams now.

Regards,

Christopher



More information about the ffmpeg-devel mailing list