What is MXF?
- MXF organizes the media content inside the file in several tracks.
- Each track can be encoded in a different video or audio format
MXF has been around for many years. Back in 2005, it was already used by Panasonic cameras using P2 storage (DVCPRO format).
Recently, the success of XDCAM HD422 camcorders like Sony PWM-200 and of Canon XF products like Cinema EOS C300 has given MXF a promiment place in professional workflows.
New 4K and Cinema formats like XAVC, Sony RAW and CinemaDNG use MXF as their container format.
MXF has several strong points:
- Robustness: It's a very redundant format, which makes the recovery of corrupt files possible
- Workflow-friendly: It stores timecode and rich metadata, on a per-frame basis.
- Interoperability: MXF can be read and written by a variety of software, including AVID Media Composer, Adobe Premiere, Sony Vegas, GrassValley EDIUS and Final Cut
Structure of MXF files
To analyze MXF files, you can use several utilities.
For example, MXFDump comes bundled with AVID Media Composer. In Mac OS X, this utility is installed in /Applications/Utilities/AVID Utilities Dumpers folder.
The first page of a "dump" looks like this: (see below)
[ K = Header ( 0000000000000000 ) 06.0e.2b.34.02.05.01.01.0d.01.02.01.01.02.04.00, L = 136 (88) ] Major Version = 0001 Minor Version = 0003 KAGSize = 00000200 ThisPartition = 0000000000000000 PreviousPartition = 0000000000000000 FooterPartition = 0000000005b4a400 HeaderByteCount = 0000000000014000 IndexByteCount = 0000000000000000 IndexSID = 00000000 BodyOffset = 0000000000000000 BodySID = 00000000 Operational Pattern = 06.0e.2b.34.04.01.01.01.0d.01.02.01.01.01.09.00 = [ 1a - Single Item, Single Package ] EssenceContainers = [ count = 3 ] 0 = 06.0e.2b.34.04.01.01.02.0d.01.03.01.02.04.60.01 = [ MPEG Elementary Stream - stream id 0x60 (frame wrapped) ] 1 = 06.0e.2b.34.04.01.01.01.0d.01.03.01.02.06.03.00 = [ AES3/BWF - AES3 (frame wrapped) ] 2 = 06.0e.2b.34.04.01.01.03.0d.01.03.01.02.7f.01.00 = [ Not recognized ] [ K = KLVFill ( 000000000000009c ) 06.0e.2b.34.01.01.01.02.03.01.02.10.01.00.00.00, L = 336 (150) ] [ K = Primer ( 0000000000000200 ) 06.0e.2b.34.02.05.01.01.0d.01.02.01.01.05.01.00, L = 1736 (6c8) ] [ Number of entries = 96, Entry size = 18 ] Local Tag UID 02.01 : 06.0e.2b.34.01.01.01.02.04.07.01.00.00.00.00.00
Note that information is structured in "atoms" that have the following attributes:
- Atom Type Ex: Header, KLV Fill, Primer, ...
- Atom Signature Ex: 06.0e.2b.34.02.05.01.01.0d.01.02.01.01.02.04.00 for Header (always 16 bytes starting with 06 0e 2b 34 word.
- Atom Address and Length Ex: KLVFill starts at address 0x9c and has a length of 336 bytes
The Header atom also declares the video and audio formats used in the file. Here, we have a MPEG Elementary Stream (actually XDCAM HD422) and AES3 audio (Linear PCM).
KLVFill atoms don't contain information. They just add padding so that the next atom starts on a "round" address, like 0x200 for Primer.
We have 4 top-level structures.
Header Body IndexTableSegment SystemMetadata Essence Element (Video) Essence Element x number of Audio channels ... ... repeat x number of video frames Footer RandomIndexMetadata
- Header and Footer are almost identical. They declare all the audio and video settings, and how tracks are organized.
- Body is by far the biggest section of the file. It contains one or several indexes and frames made of a SystemMetadat and several Essence Elements. Essence Elements is where actual media is stored.
- An optional RandomIndexMetadata will optimize random access inside the video file.
Header and Footer
Header and Footage contain complex substructures: (KLVFill atoms have been omitted for clarity)
Header Primer MXFPreface MXFIdentification MXFContentStorage MXFMaterialPackage x times (one per track) MXFTrack MXFSequence MXFSourceClip or MXFTimeCodeComponent MXFSourcePackage x times (one per track) MXFTrack MXFSequence MXFSourceClip or MXFTimeCodeComponent MXFMultipleDescriptor MXFGenericPictureEssenceDescriptor x times MXFAES3PCMDescriptor Dark Atom (proprietary information) MXFEssenceContainerData
Some atoms contain information that can easily by understood:
Inside MXFMPEG2VideoDescriptor: [ k = DisplayHeight 32.08, l = 4 (0004) ] 0 00 00 04 38 ...8 [ k = DisplayWidth 32.09, l = 4 (0004) ] 0 00 00 07 80 .... Inside MXFTrack: [ k = EditRate 4b.01, l = 8 (0008) ] 0 00 00 5d c0 00 00 03 e9 ..].....
- 07 80 and 04 38 in hexadecimal represent 1920x1080 resolution (fullHD)
- 5d c0 and 03 e9 represent 1001/24000, or 23.976 frames per second
Corrupt MXF Files
Most common Failure Modes
- CF card formatted in camera or deleted accidentally
- Compact Flash card became corrupt and MXF files were recovered using disk recovery software
- A full CF card was put in camera instead of a blank one, footage was overwritten with new content before operator could dump the data off of it
- Last clip on Canon CF card is unplayable. Rest of clips are OK
- Card failed to copy data across on computer
- Everything transferred correctly but movie was corrupted on computer hard drive.
Fixing Corrupt MXF Files
Corrupt MXF files don't have a coherent structure. In the worst case, there is only raw data belonging to the Body section.
Therefore, to repair them, it's necessary to organize the data, re-creating the Header, Body and Footer structures.
Copying and pasting together existing valid structures (from other playable MXF files) won't work, because every MXF file has a unique Body size, duration, and timecode.
To make things worse, audio and video media can be recorded in separate files, causing raw data to be interleaved after a data recovery: You can find an audio frame in the middle of a video frame. Usually those interruptions happen on addresses multiple of 0x80000, but it makes MXF recovery much more difficult.
At Aero Quartet, we have developed MXF repair algorithms for most common situations. If you need to repair corrupt MXF, please download our free diagnostics app Treasured and send us a request.