MP4 output
MP4 is the most popular video format available for all platforms. Typically, AAC is used to encode the audio stream, and H264 or HEVC codecs are used to encode the video stream.
Use the MP4SinkSettings
class to set the parameters.
Block info
Name: MP4SinkBlock.
Pin direction | Media type | Pins count |
---|---|---|
Input audio | audio/mpeg | one or more |
audio/x-ac3 | ||
audio/x-alac | ||
audio/x-opus | ||
Input video | video/mpeg | one or more |
video/x-divx | ||
video/x-h264 | ||
video/x-h265 | ||
video/x-av1 | ||
Input subtitle | text/utf8 | one or more |
The sample pipeline
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp4";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
var aacEncoderBlock = new AACEncoderBlock(new MFAACEncoderSettings() { Bitrate = 192 });
pipeline.Connect(fileSource.AudioOutput, aacEncoderBlock.Input);
var h264EncoderBlock = new H264EncoderBlock(new MFH264EncoderSettings());
pipeline.Connect(fileSource.VideoOutput, h264EncoderBlock.Input);
var mp4SinkBlock = new MP4SinkBlock(new MP4SinkSettings("output.mp4"));
pipeline.Connect(h264EncoderBlock.Output, mp4SinkBlock.CreateNewInput(MediaBlockPadMediaType.Video));
pipeline.Connect(aacEncoderBlock.Output, mp4SinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));
await pipeline.StartAsync();
Sample applications
Platforms
Windows, macOS, Linux, iOS, Android.