#
MP2 encoder
MP2 (MPEG-1 Audio Layer II)
: An older, lossy audio compression format that is less complex than MP3, commonly used in broadcasting and digital radio due to its robustness.
An MP2 encoder can be used to encode audio streams in formats like MPEG-TS or VOB.
Use the MP2EncoderSettings
class to set the parameters.
#
Block info
Name: MP2EncoderBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->MP2EncoderBlock; UniversalSourceBlock-->MPEG2EncoderBlock; MP2EncoderBlock-->MPEGTSSinkBlock; MPEG2EncoderBlock-->MPEGTSSinkBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp4";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
var audioEncoderBlock = new MP2EncoderBlock(new MP2EncoderSettings());
pipeline.Connect(fileSource.AudioOutput, audioEncoderBlock.Input);
var h264EncoderBlock = new H264EncoderBlock(new OpenH264EncoderSettings());
pipeline.Connect(fileSource.VideoOutput, h264EncoderBlock.Input);
var tsSinkBlock = new MPEGTSSinkBlock(new MPEGTSSinkSettings(@"output.ts"));
pipeline.Connect(h264EncoderBlock.Output, tsSinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(audioEncoderBlock.Output, tsSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android