Skip to main content

File sink

Universal output to a file. This sink is used inside all other higher-level sinks, e.g. MP4Sink. Can be used to write RAW video or audio to a file.

Block info

Name: FileSinkBlock.

Pin directionMedia typePins count
InputAny stream format1

The sample pipeline

UniversalSourceBlock:AudioOutput MP3EncoderBlock FileSinkBlock

Sample code

var pipeline = new MediaBlocksPipeline(false);

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

var mp3EncoderBlock = new MP3EncoderBlock(new MP3EncoderSettings() { Bitrate = 192 });
pipeline.Connect(fileSource.AudioOutput, mp3EncoderBlock.Input);

var fileSinkBlock = new FileSinkBlock(@"output.mp3");
pipeline.Connect(mp3EncoderBlock.Output, fileSinkBlock.Input);

await pipeline.StartAsync();

Platforms

Windows, macOS, Linux, iOS, Android.