Skip to main content

WebM output

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 directionMedia typePins count
Input audiox-vorbisone or more
audio/x-opus
Input videovideo/x-vp8one or more
video/x-vp9
video/x-av1
Input subtitletext/utf8one or more
subtitle/x-kate
application/x-ssa
application/x-ass
application/x-usf
subpicture/x-dvd

The sample pipeline

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.