MP3 Audio Encoder

The Microsoft Media Foundation MP3 audio encoder is a Media Foundation Transform (MFT) that encodes MPEG-1 layer 3 (MP3) audio.

Class Identifier

The class identifier (CLSID) of the MP3 encoder is CLSID_MP3ACMCodecWrapper, defined in the header file wmcodecdsp.h.

Media Types

The MP3 encoder supports the following media types. The output type must be set before the input type.

Output Types

Set the following attributes on the output media type.

Attribute Description Remarks
MF_MT_MAJOR_TYPE Major type. Must be MFMediaType_Audio.
MF_MT_SUBTYPE Audio subtype. Must be MFAudioFormat_MP3.
MF_MT_AUDIO_AVG_BYTES_PER_SECOND Bit rate of the encoded MP3 stream, in bytes per second. The encoder supports all bit rates defined by the standard (32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, or 320 Kbps).
The default bit rates are 128 Kbps for mono and 320 Kbps for stereo.
Use this attribute to specify the encoded bit rate.
MF_MT_AUDIO_NUM_CHANNELS Number of channels. The following values are supported:
  • 1 (mono)
  • 2 (stereo)
MF_MT_AUDIO_SAMPLES_PER_SECOND Samples per second. The following values are supported:
  • 48000 (48 KHz)
  • 44100 (44.1 KHz)
  • 32000 (32 KHz)
MF_MT_USER_DATA Additional codec data. This attribute contains the 12 bytes of the MPEGLAYER3WAVEFORMAT structure that follow the wfx member of that structure.

 

Alternatively, you can fill in an MPEGLAYER3WAVEFORMAT structure and call MFInitMediaTypeFromWaveFormatEx to convert the structure to a Media Foundation media type.

Input Types

Set the following attributes on the input media type.

Attribute Description Remarks
MF_MT_MAJOR_TYPE Major type. Must be MFMediaType_Audio.
MF_MT_SUBTYPE Subtype. Must be MFAudioFormat_PCM.
MF_MT_AUDIO_BITS_PER_SAMPLE Bits per sample. Must be 16.
MF_MT_AUDIO_SAMPLES_PER_SECOND Samples per second. Must match the output type.
MF_MT_AUDIO_NUM_CHANNELS Number of channels. Must match the output type.

 

The encoder supports only 16-bit integer PCM input. It does not support 32-bit floating point input.

Media Formats

The MPEG-1 and MPEG-2 standard defines 252 layer 3 audio formats. The MP3 encoder supports the standard with some exceptions, as well as some additional formats, as described below. Layer 3 is defined as:

Requirement Value
Channels mono or stereo
MPEG-1 sample rates in kHz 44.1, 48, 32
MPEG-1 encoded bit rates in kbps 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320
MPEG-2 sample rates in kHz 8, 11.025, 12, 16, 22.05, 24
MPEG-2 encoded bit rates in kbps 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 144, 160

 

The MP3 encoder also supports the following formats.

Sample Rate Bit Rate Channel Number
8000 18000, 20000 2
11025 18000, 20000 1 or 2
12000 18000, 20000 1 or 2
16000 18000, 20000 1
32000 144000 1 or 2
44100 144000 1 or 2
48000 144000 1 or 2

 

The MP3 encoder does not support the following formats defined by the standard.

Sample Rate Bit Rates Channel Number
12000 80000, 96000, 112000, 128000, 144000, 160000 1 or 2
11025 80000, 96000, 112000, 128000, 144000, 160000 1 or 2
8000 80000, 96000, 112000, 128000, 144000, 160000 1 or 2
8000 8000, 11025, 12000, 16000, 22050, 24000 2

 

Requirements

Requirement Value
Minimum supported client
Windows 8 [desktop apps only]
Minimum supported server
Windows Server 2012 [desktop apps only]

See also

Codec Objects