# WebM output

Media Blocks SDK .Net

WebM is used on the Internet as a free alternative to the MP4 format, using the VP8/VP9 codec for video and Vorbis for audio.

Use the WebMSinkSettings class to set the parameters.

# Block info

Name: WebMSink.

Pin direction Media type Pins count
Input audio x-vorbis one or more
audio/x-opus
Input video video/x-vp8 one or more
video/x-vp9
video/x-av1
Input subtitle text/utf8 one or more
subtitle/x-kate
application/x-ssa
application/x-ass
application/x-usf
subpicture/x-dvd

# The sample pipeline

graph LR;
    UniversalSourceBlock-->VPXEncoderBlock;
    UniversalSourceBlock-->VorbisEncoderBlock;
    VPXEncoderBlock-->WebMSink;
    VorbisEncoderBlock-->WebMSink;

# Sample code

The following sample code can convert the source video file to the WebM file with a VP8 video stream and Vorbis audio stream.

var pipeline = new MediaBlocksPipeline();

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

 var vp8EncoderBlock = new VPXEncoderBlock(new VP8EncoderSettings());
pipeline.Connect(fileSource.VideoOutput, vp8EncoderBlock.Input);

var vorbisEncoderBlock = new VorbisEncoderBlock(new VorbisEncoderSettings() { Bitrate = 192 });
pipeline.Connect(fileSource.AudioOutput, vorbisEncoderBlock.Input);

var webmSinkBlock = new WebMSinkBlock(new WebMSinkSettings(@"output.webm"));
pipeline.Connect(vp8EncoderBlock.Output, webmSinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(vorbisEncoderBlock.Output, webmSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));

await pipeline.StartAsync();

# Platforms

Windows, macOS, Linux, iOS, Android.