MXF Output
MXF (Material Exchange Format) is a professional video container format widely used in broadcast and post-production workflows. This guide explains how to use the MXF output functionality in the VisioForge SDKs.
Basic Usage
To create an MXF output, you'll need to specify:
- Output filename
- Video stream type
- Audio stream type
- Optional video encoder settings
- Optional audio encoder settings
Here's a basic example:
var mxfOutput = new MXFOutput(
filename: "output.mxf",
videoStreamType: MXFVideoStreamType.H264,
audioStreamType: MXFAudioStreamType.MPEG
);
Supported Video Encoders
The following video encoders are supported:
- OpenH264 - Basic H.264 encoder
- QSV H264 - Intel Quick Sync Video H.264 encoder
- NVENC H264 - NVIDIA H.264 encoder
- AMF H264 - AMD H.264 encoder
- MF HEVC - Media Foundation HEVC encoder (Windows only)
- QSV HEVC - Intel Quick Sync Video HEVC encoder
- NVENC HEVC - NVIDIA HEVC encoder
- AMF H265 - AMD HEVC/H.265 encoder
To set a specific video encoder:
mxfOutput.Video = new NVENCH264EncoderSettings();
Supported Audio Encoders
Available audio encoders include:
- MP3 - Standard MP3 encoder
- VO-AAC - VisioForge AAC encoder
- AVENC AAC - FFMPEG AAC encoder
- MF AAC - Media Foundation AAC encoder (Windows only)
Example of setting an audio encoder:
mxfOutput.Audio = new MP3EncoderSettings();
Custom Processing
The MXF output supports custom processing for both video and audio:
// Add custom video processing
mxfOutput.CustomVideoProcessor = yourVideoProcessingBlock;
// Add custom audio processing
mxfOutput.CustomAudioProcessor = yourAudioProcessingBlock;
Sink Settings
The MXF sink settings control the output file configuration:
// Access sink settings
mxfOutput.Sink.Filename = "new_output.mxf";
Best Practices
Encoder Selection:
- Choose hardware encoders (NVENC, QSV, AMF) when available for better performance
- Fall back to OpenH264 for maximum compatibility
Audio Encoding:
- Use MF AAC on Windows for optimal performance
- Use MP3 or VO-AAC on other platforms
File Management:
- Use GetFilename() and SetFilename() methods for file path handling
- Ensure write permissions in the output directory
Error Handling
While the code doesn't explicitly show error handling, you should:
- Verify encoder availability before use
- Handle file access permissions
- Check for null references when working with optional components
Example Implementation
Here's a complete example showing how to set up MXF output with custom settings:
// Create MXF output with specific stream types
var mxfOutput = new MXFOutput(
filename: "output.mxf",
videoStreamType: MXFVideoStreamType.H264,
audioStreamType: MXFAudioStreamType.MPEG
);
// Configure video encoder (prefer hardware acceleration if available)
if (NVENCH264EncoderSettings.IsAvailable())
{
mxfOutput.Video = new NVENCH264EncoderSettings();
}
else
{
mxfOutput.Video = new OpenH264EncoderSettings();
}
// Configure audio encoder based on platform
#if NET_WINDOWS
mxfOutput.Audio = new MFAACEncoderSettings();
#else
mxfOutput.Audio = new MP3EncoderSettings();
#endif