AAC encoder
The VisioForge SDK provides several AAC encoder implementations, each with unique characteristics and use cases.
Cross-platform M4A (AAC) output (X-engines: VideoCaptureCoreX, VideoEditCoreX, Media Blocks)
This guide will explore the four primary AAC encoder types:
- AVENC AAC Encoder
- VO-AAC Encoder
- Media Foundation AAC Encoder (used in Windows-only engines)
AVENC AAC Encoder
The AVENC AAC Encoder offers the most comprehensive configuration options for audio encoding. It provides advanced settings for stereo coding, prediction, and noise shaping.
Key Features
- Multiple coder strategies
- Configurable stereo coding
- Advanced noise and prediction techniques
Coder Strategies
The AVENC AAC Encoder supports three coder strategies:
ANMR
: Advanced noise modeling and reduction methodTwoLoop
: Two-loop searching method for optimizationFast
: Default fast search algorithm (recommended for most use cases)
Sample Configuration
var aacSettings = new AVENCAACEncoderSettings
{
Coder = AVENCAACEncoderCoder.Fast,
Bitrate = 192,
IntensityStereo = true,
ForceMS = true,
TNS = true
};
Supported Parameters
- Bitrates: 0, 32, 64, 96, 128, 160, 192, 224, 256, 320 kbps
- Sample Rates: 7350 to 96000 Hz
- Channels: 1 to 6 channels
VO-AAC Encoder
The VO-AAC Encoder is a more streamlined encoder with simpler configuration options.
Key Features
- Simplified configuration
- Straightforward bitrate and sample rate controls
- Limited to stereo audio
Sample Configuration
var aacSettings = new VOAACEncoderSettings
{
Bitrate = 128
};
Supported Parameters
- Bitrates: 32, 64, 96, 128, 160, 192, 224, 256, 320 kbps
- Sample Rates: 8000 to 96000 Hz
- Channels: 1-2 channels
Media Foundation AAC Encoder (Windows Only)
This encoder is specific to Windows platforms and offers a limited but performance-optimized encoding solution.
Key Features
- Windows-specific implementation
- Predefined bitrate options
- Limited sample rate support
Supported Parameters
- Bitrates: 0 (Auto), 96, 128, 160, 192, 576, 768, 960, 1152 kbps
- Sample Rates: 44100, 48000 Hz
- Channels: 1, 2, 6 channels
Encoder Availability and Selection
Each encoder provides a static IsAvailable()
method to check if the encoder can be used in the current environment. This is useful for runtime compatibility checks.
if (AVENCAACEncoderSettings.IsAvailable())
{
// Use AVENC AAC Encoder
}
else if (VOAACEncoderSettings.IsAvailable())
{
// Fallback to VO-AAC Encoder
}
Rate Control Considerations
-
AVENC AAC Encoder:
- Most flexible rate control
- Supports constant bitrate (CBR)
- Multiple encoding strategies affect quality and performance
-
VO-AAC Encoder:
- Simple constant bitrate control
- Recommend for straightforward encoding needs
- Limited advanced configuration
-
Media Foundation Encoder:
- Limited to predefined bitrates
- Good for quick Windows-based encoding
- Auto bitrate option available
Recommendations
- For advanced audio encoding with maximum control, use AVENC AAC Encoder
- For simple, cross-platform encoding, use VO-AAC Encoder
- For Windows-specific, optimized encoding, use Media Foundation Encoder
Performance and Quality Considerations
- Higher bitrates generally mean better audio quality
- Choose sample rates matching your source audio
- Consider your target platform and audience when selecting an encoder
Sample Code
- Check the M4A output and MP4 output guides for sample code.
- Check the AAC encoder block for sample code.
Windows-only AAC output (VideoCaptureCore and VideoEditCore engines)
M4AOutput is the primary class for configuring M4A (AAC) output settings. It implements both IVideoEditBaseOutput
and IVideoCaptureBaseOutput
interfaces.
Properties
Property | Type | Description | Default Value |
---|---|---|---|
Version | AACVersion | Specifies the AAC version (MPEG-2 or MPEG-4) | MPEG4 |
Object | AACObject | Defines the AAC object type | Low |
Output | AACOutput | Sets the AAC output mode | RAW |
Bitrate | int | Specifies the AAC bitrate in kbps | 128 |
Methods
GetInternalTypeVC()
- Returns:
VideoCaptureOutputFormat.M4A
- Purpose: Gets the internal output format for video capture
GetInternalTypeVE()
- Returns:
VideoEditOutputFormat.M4A
- Purpose: Gets the internal output format for video editing
Save()
- Returns: JSON string representation of the M4AOutput object
- Purpose: Serializes the current configuration to JSON
Load(string json)
- Parameters: JSON string containing M4AOutput configuration
- Returns: New M4AOutput instance
- Purpose: Creates a new M4AOutput instance from JSON configuration
Supporting Enums
AACVersion
Defines the version of AAC to be used:
Value | Description |
---|---|
MPEG4 | MPEG-4 AAC (default) |
MPEG2 | MPEG-2 AAC |
AACObject
Specifies the AAC encoder stream object type:
Value | Description |
---|---|
Undefined | Not to be used |
Main | Main profile |
Low | Low Complexity profile (default) |
SSR | Scalable Sample Rate profile |
LTP | Long Term Prediction profile |
AACOutput
Determines the AAC encoder stream output type:
Value | Description |
---|---|
RAW | Raw AAC stream (default) |
ADTS | Audio Data Transport Stream format |
Usage Example
// Create new M4A output configuration
var m4aOutput = new M4AOutput
{
Version = AACVersion.MPEG4,
Object = AACObject.Low,
Output = AACOutput.RAW,
Bitrate = 192
};
core.Output_Format = m4aOutput; // core is an instance of VideoCaptureCore or VideoEditCore
Best Practices
-
Bitrate Selection
- Choose appropriate bitrate based on quality requirements
- Standard bitrates: 96-320 kbps
- Default: 128 kbps (good balance of quality and file size)
-
AAC Object Type
- Use Low (LC) profile for most applications
- Main profile for higher quality requirements
- Avoid Undefined
-
Version Selection
- MPEG4 recommended for better compatibility
- Use MPEG2 only for legacy system requirements
-
Output Format
- RAW: For system-level integration
- ADTS: Better for streaming and compatibility