Posted in: MXF, Video_wrapper

How to get metadata from MXF file

How to get metadata from MXF file

MXF (Material Exchange Format) files are complex container files used primarily for professional video and audio workflows. They encapsulate not only the media essence but also an extensive set of metadata—usually encoded in a Key-Length-Value (KLV) structure—that describes aspects of the media (such as timecode, essence descriptors, operational patterns, and application-specific metadata). Parsing metadata from an MXF file involves both an understanding of its internal structure and selecting the right set of tools or libraries to extract and interpret that information.

Below is a detailed guide on how to approach parsing metadata from an MXF file:

1. Understand the MXF Structure and KLV Encoding

MXF Container and Metadata:

  • Container Format: MXF is designed for interchange and archival of media, and as such, it supports embedding both multiple streams (audio, video, ancillary data) and a rich set of metadata.
  • KLV Structure: Metadata in MXF is typically stored using the SMPTE standards (e.g., SMPTE 377M), where each metadata entry is encoded as a KLV packet:
    • Key: A unique identifier (typically a 16-byte value) that tells you what type of information is following.
    • Length: Indicates the length of the data payload.
    • Value: The actual metadata data, which can be numeric, textual, binary, or even another nested set of KLV packets.

Key Insight: Understanding which keys correspond to which metadata fields is crucial. Industry standards (like SMPTE 379M, 382M, and 429-6) provide definitions for many of these keys, although proprietary extensions are common.

2. Choose the Right Tool or Library

There are several strategies depending on your needs, expertise, and environment:

a. Using Media Analysis Tools

  • FFmpeg/FFprobe:
    FFprobe (part of the FFmpeg suite) can extract a lot of high-level metadata from MXF files:

    ffprobe -v quiet -print_format json -show_format -show_streams yourfile.mxf
    

    This command outputs metadata in JSON format, which you can then parse using your favorite programming language. Keep in mind that FFprobe may only expose certain metadata elements and might not give you every KLV packet.

  • MediaInfo:
    The MediaInfo tool can display a variety of metadata details from MXF files in both command-line and GUI forms.

b. Using Dedicated MXF Libraries

  • MXF Parsing Libraries:
    Depending on your programming language, you might find libraries that specifically target MXF parsing:

    • C/C++: Libraries such as libMXF or tools implemented by broadcast vendors may offer in-depth access to KLV metadata.
    • Python: Although there isn’t a one-size-fits-all package, you can consider using Python’s binary data manipulation libraries (such as struct or bitstring) to manually parse KLV data once you’ve identified the packet boundaries. There are also community projects and wrappers you might find on repositories like GitHub that can serve as starting points.

3. Parsing the Metadata Programmatically

If you choose to parse the KLV metadata manually (or with a custom library), here’s an overview of the process:

a. Open the MXF File in Binary Mode

Use your programming language’s file I/O routines (e.g., in Python, use open(filename, 'rb')).

b. Locate the MXF Partitions

MXF files are organized in partitions. The header partition typically contains the essence descriptors and core metadata:

  • Partition Pack: Contains pointers to where metadata and essence data are stored.
  • You might need to scan for the partition pack markers to determine the structure.

c. Extract and Interpret KLV Packets

Once you locate the metadata section:

  • Read the Key: Usually a fixed length (often 16 bytes).
  • Interpret the Length Field: The length field itself might be a BER (Basic Encoding Rules) encoded integer.
  • Read the Value: Based on the length you just determined.
  • Interpretation: Based on the key, you can then interpret the value. For example:
    • Some keys correspond to timecodes.
    • Others might be version numbers or application-specific data.
    • Cross-reference the key with SMPTE documentation to decode it accurately.

d. Example Code Snippet (Python)

Below is a simplistic illustrative snippet using Python to showcase reading a KLV packet:

import struct
     
def parse_klv_packet(data, offset):
    # Assuming the key is 16 bytes long
    key = data[offset:offset+16]
    offset += 16
         
    # Length field: here we assume a simple 4-byte integer for illustration (actual MXF uses BER)
    length = struct.unpack('>I', data[offset:offset+4])[0]
    offset += 4
         
    # Value data: extract based on the computed length
    value = data[offset:offset+length]
    offset += length
         
    return key, length, value, offset
     
# Open the MXF file in binary mode
with open("yourfile.mxf", "rb") as f:
    mxf_data = f.read()
     
# Assume we know the offset to metadata (this requires proper partition scanning)
offset = 0  
while offset < len(mxf_data):
    try:
        key, length, value, offset = parse_klv_packet(mxf_data, offset)
        # Process your key/value pair
        print("Key:", key.hex())
        print("Length:", length)
        print("Value (raw):", value)
        # Here you may want to parse 'value' based on known key mappings
    except Exception as e:
        print("Error parsing KLV packet:", e)
        break

Note: The above code oversimplifies the handling of the length field; MXF actually uses a BER (Basic Encoding Rules) encoded length field, which may require a more sophisticated parser to handle variable-length integers.

4. Consult the MXF Standards and Documentation

For accurate decoding, refer to the relevant SMPTE documents:

  • SMPTE 377M: Core MXF file format.
  • SMPTE 379M and 382M: Descriptors and operational patterns.
  • SMPTE 429-6: KLV data specifications.

These documents provide detailed information on key definitions, required metadata fields, and the structure of KLV encoding.

5. Use Community Tools and Forums

Consider exploring community resources such as:

  • GitHub Projects: Look for open-source projects where developers have shared MXF parsers.

  • Professional Forums: Broadcast engineering communities often discuss these topics in detail.

Summary

To parse metadata from an MXF file:

  1. Understand the MXF format and KLV structure.
  2. Select your tools or libraries: Use FFprobe, MediaInfo, or dedicated MXF parsing libraries.
  3. Implement or use an existing parser: Whether manually (with code handling the KLV structure) or via a tool that abstracts these details.
  4. Consult the MXF standards: For comprehensive details on each metadata field.
  5. Explore community resources: To aid and validate your approach.

This approach should provide a strong basis for extracting and interpreting the metadata embedded in MXF files.

Any MXF standards defined metadata ‘Original Frame Rate’

the “Original Frame Rate” is a metadata item that is defined in certain MXF standards—particularly those that use Descriptive Metadata Schemes (DMS) or Essence Descriptors—to describe the native or acquisition frame rate of the content. Here’s a breakdown of where and how it is defined:

1. SMPTE 377M – MXF File Format Specification

This is the foundational standard for MXF files, but it mainly outlines the container format, partition structure, and KLV encoding. It does not define specific metadata like “Original Frame Rate” directly, but refers to other standards for descriptors and metadata schemes.

2. SMPTE 381M – Essence Container for Picture

This standard defines Generic Picture Essence Descriptors, which include frame rate metadata fields.

  • EditRate: Indicates the rate at which essence is intended to be edited or played.
  • SampleRate: In the case of picture essence (e.g., video), it can refer to the actual frame rate.

But neither of these is explicitly “Original Frame Rate”. Rather, they are operational frame rates of the stored essence.

3. SMPTE 380M – Descriptive Metadata Scheme-1 (DMS-1)

This is where user-defined or descriptive metadata like “Original Frame Rate” may be defined or extended.

In SMPTE 380M, you can define sets like:

  • Production Metadata Set
  • Camera Parameters Set
  • Original Source Clip Metadata Set

These may contain attributes like:

  • OriginalFrameRate (often expressed as a rational number, like 24/1 for 24fps)

So: “Original Frame Rate” is usually found in DMS metadata, either standardized or extended by a specific application (like Avid, Sony, or Adobe), and may be stored in:

  • Descriptive Metadata (DMS)
  • Preface/Content Storage Metadata
  • Essence Descriptors (sometimes as EditRate or SampleRate, but not exactly “original”)

4. Application-Specific MXF Variants

Many MXF-producing applications embed “Original Frame Rate” using their own metadata sets. Examples include:

  • Sony XDCAM MXF: stores it in proprietary XML metadata.
  • Avid MXF: may include it in MOB (Material Object) metadata or as part of AS-03/AS-11 standards.

If you run:

ffprobe -show_format -show_streams yourfile.mxf

You might see something like:

TAG:frame_rate=24/1
TAG:original_frame_rate=24/1

But whether this appears depends on:

  • The application that created the MXF
  • Whether that metadata was populated
  • The capabilities of the parsing tool

Summary

FieldPresent InNotes
OriginalFrameRateSMPTE 380M (DMS)Often user-defined, rational number
EditRate, SampleRateSMPTE 381M (Essence)Describes essence playback, not necessarily original
original_frame_rate (tag)Application-specificMay appear via tools like FFprobe or MediaInfo
Other tagse.g., AcquisitionRateIn some DMS extensions (like for cameras)

Is “Original Frame Rate” info stored in MXF wrapper or in video?

The “Original Frame Rate” can be stored in either the MXF wrapper (i.e. the metadata layer) or not at all, but it is never embedded in the video essence (the raw video data itself).

So the answer is:

“Original Frame Rate” is stored—when present—in the MXF wrapper (metadata), not in the video essence.

MXF Structure at a Glance

An MXF file is made up of two main parts:

  • Essence: the raw audio, video, or data streams (e.g., H.264, DNxHD, etc.)
  • Metadata (the MXF wrapper): includes descriptive, structural, and technical metadata

The “Original Frame Rate” is metadata about the content, not an attribute of the encoded video stream itself.

Where It May Be Stored in the MXF Wrapper:

  1. Essence Descriptor (e.g., Generic Picture Essence Descriptor)
    • Includes SampleRate or EditRate – describes the current stored framerate, not necessarily the “original”
  2. Descriptive Metadata Sets (DMS) – SMPTE 380M
    • May include fields like OriginalFrameRate or AcquisitionFrameRate
    • Often used in professional workflows (Sony XDCAM, Avid, etc.)
  3. Application-Specific Metadata
    • Some vendors extend MXF metadata with proprietary tags (e.g., Sony stores additional XML, Avid uses MOB metadata)

Not Stored in:

  • The video stream/essence itself (e.g., the encoded H.264 or DNxHD data) – those frames do not “know” the original frame rate in isolation

Example: How to Detect It

You can use ffprobe, mediainfo, or MXF SDKs (e.g., from Sony or BBC) to extract it if present:

mediainfo input.mxf

Look for:

  • Original frame rate
  • Acquisition frame rate
  • Frame rate mode: Constant
  • In JSON: media.track[].FrameRate or custom OriginalFrameRate

What’s the exact define of ‘Original Frame Rate’ in SMPTE 380M

In SMPTE 380M (Descriptive Metadata Scheme 1 – DMS-1), the term “Original Frame Rate” is not explicitly defined with that exact label, but a closely related concept exists and can be expressed via a combination of descriptive metadata sets.

Here’s a breakdown of what SMPTE 380M provides, and how Original Frame Rate would typically be represented:

SMPTE 380M: DMS-1 Overview

SMPTE 380M defines a framework for embedding descriptive metadata in MXF files. It uses sets and attributes, structured as key-length-value (KLV) packets, that describe things like:

  • Clip creation
  • Camera settings
  • Production info
  • Source attributes (including acquisition frame rate)

Closest Equivalent to “Original Frame Rate”

The Camera Parameters Set or Production Metadata Set within DMS-1 may contain attributes such as:

  • AcquisitionFrameRate
  • EditRate
  • VideoFormat

Example: AcquisitionFrameRate

This is the field that is typically used to express what is commonly meant by “Original Frame Rate” — the frame rate at which the material was originally recorded by the camera.

  • Field name: AcquisitionFrameRate
  • Data type: Rational (e.g., 24/1 for 24 fps)
  • Defined in: Camera Parameters Set (UUID-defined in SMPTE RP210)

This field is distinct from:

  • EditRate – the rate at which the material is intended to be played or edited
  • SampleRate – the actual sample rate used in essence encoding (could differ from acquisition)

Summary

TermDefined inRepresents
AcquisitionFrameRateDMS-1 / Camera SetOriginal recording rate
EditRateMXF structural metadataPlayback or edit speed (may differ)
SampleRateEssence descriptorRate of video samples (e.g., 30fps)
OriginalFrameRateNot exact termGenerally refers to AcquisitionFrameRate

Practical Implication

If you’re parsing an MXF file and trying to find the “Original Frame Rate,” you’re really looking for:

  • AcquisitionFrameRate in the DMS metadata
  • OR equivalent field in vendor-specific sets (e.g., Sony XML sidecar, Avid MOB metadata)

Do you know if any bug for this MXF wrapper? Sony MXF Development Kit (Win32) 4.8.0.113.1

As of now, there are no publicly documented bugs or issues specifically associated with the Sony MXF Development Kit (Win32) version 4.8.0.113.1. This version has been utilized in applications like Sony Vegas Pro 13 for writing MXF files, and no known problems have been reported in that context.

However, it’s important to note that while the development kit itself doesn’t have reported issues, some users have encountered challenges when working with MXF files in various editing environments. For instance, certain versions of Adobe Premiere Pro have exhibited playback glitches and decoding errors with MXF files, particularly those encoded in formats like XAVC-L or Canon XF-AVC. These issues are often related to hardware decoding settings rather than the MXF files themselves. Disabling hardware decoding in the application preferences has been reported as a potential workaround in some cases.Reddit+1vegascreativesoftware.info+1

If you’re experiencing specific problems with MXF files produced using this development kit, could you provide more details about the issue? Information such as the software you’re using to open the files, the nature of the problem (e.g., playback issues, metadata discrepancies), and any error messages received would be helpful in diagnosing the problem and suggesting a solution.

Where did MXF wrapper get information of original frame rate? from Video? if the recorded video been edited, can MXF wrapper still get original frame rate info?

The MXF wrapper does *not* extract or infer the “Original Frame Rate” from the video essence. Instead:

Where Does the MXF Wrapper Get “Original Frame Rate” Info?

  1. From metadata provided by the capture system (e.g., camera or ingest software)
    • Cameras (like Sony XDCAM or ARRI) write this info directly into MXF metadata, often into:
      • Descriptive Metadata Set (DMS-1) — e.g., AcquisitionFrameRate
      • Camera-specific XML or proprietary sidecar metadata
    • If a recording was made at 59.94 fps but intended to be played back at 23.976 fps (overcranking), both values might be stored.
  2. From authoring or editing software during export
    • If you’re exporting from something like Adobe Premiere or DaVinci Resolve, the software can insert “original frame rate” info into the MXF metadata — but only if it’s been told or retains that data.
    • Otherwise, it defaults to the current timeline/output frame rate.

It Is *Not* Extracted from the Encoded Video Itself

  • Encoded video frames in MXF (e.g., H.264, DNxHD) do not contain metadata about the original recording frame rate.
  • The frame sequence might suggest a rate (e.g., 25fps), but that’s just a playback rate — not definitive proof of the original acquisition rate.

If the Recorded Video Has Been Edited:

  • The original frame rate metadata may be lost, unless the editing software:
    • Preserves it intentionally
    • Copies it from the original MXF source
    • Adds a new custom field

By default, most editing tools do *not* retain “original frame rate” unless it’s part of a dedicated metadata workflow.

Practical Example

  • Raw camera MXF (e.g., Sony FS7) → contains AcquisitionFrameRate = 59.94
  • Edited and exported MXF from Premiere → may only contain EditRate = 23.976
    → Original acquisition frame rate is lost unless explicitly preserved

Summary

Metadata SourceContains “Original Frame Rate”?Notes
Original camera metadata✅ Often, as AcquisitionFrameRateReliable
Edited/exported MXF❌ Not guaranteedDepends on software
Video essence (raw frames)❌ NeverNot stored there
MXF wrapper metadata✅ If explicitly insertedNot inferred automatically

Leave a Reply

Back to Top