Skip to main content

AAC encoder

AAC encoder is used for encoding files in MP4, MKV, M4A and some other formats, as well as for network streaming using RTSP and HLS.

Use AACEncoderSettings class to set the parameters.

Block info

Name: AACEncoderBlock.

Pin directionMedia typePins count
InputPCM/IEEE1
OutputAAC1

The sample pipeline

FileSourceBlock AACEncoderBlock MP4SinkBlock

Sample code

var pipeline = new MediaBlocksPipeline(false);

var fileSource = new FileSourceBlock();
fileSource.Filename = "test.mp3";

var aacEncoderBlock = new AACEncoderBlock(new MFAACEncoderSettings() { Bitrate = 192 });

pipeline.Connect(fileSource.AudioOutput, aacEncoderBlock.Input);

var m4aSinkBlock = new MP4SinkBlock(new MP4SinkSettings(@"output.m4a"));
pipeline.Connect(aacEncoderBlock.Output, m4aSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));

await pipeline.StartAsync();

Platforms

Windows, macOS, Linux, iOS, Android.