# OPUS encoder

Media Blocks SDK .Net

OPUS: A versatile audio codec optimized for both music and speech, known for its low latency and adaptability to different network environments, ideal for real-time applications.

OPUS encoder is used when encoding files in OGG, and some other formats.

Use the OPUSEncoderSettings class to set the parameters.

# Block info

Name: OPUSEncoderSettings.

Pin direction Media type Pins count
Input PCM/IEEE 1
Output audio/x-opus 1

# The sample pipeline

graph LR;
    UniversalSourceBlock-->OPUSEncoderBlock;
    OPUSEncoderBlock-->OGGSinkBlock;

# Sample code

var pipeline = new MediaBlocksPipeline();

var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));

var opusEncoderBlock = new OPUSEncoderBlock(new OPUSEncoderSettings());
pipeline.Connect(fileSource.AudioOutput, opusEncoderBlock.Input);

var oggSinkBlock = new OGGSinkBlock(new OGGSinkSettings(@"output.ogg"));
pipeline.Connect(opusEncoderBlock.Output, oggSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));

await pipeline.StartAsync();

# Platforms

Windows, macOS, Linux, iOS, Android.