NatCorder
Search…
WEBMRecorder
class NatML.Recorders.WEBMRecorder : IMediaRecorder
The WEBMRecorder records *.webm video files.
The WEBMRecorder uses the VP8 codec for video and the OPUS codec for audio.
The WEBMRecorder is not supported on iOS, macOS, or Windows.

/// <summary>
/// Create a WEBM recorder.
/// </summary>
/// <param name="width">Video width.</param>
/// <param name="height">Video height.</param>
/// <param name="frameRate">Video frame rate.</param>
/// <param name="sampleRate">Audio sample rate. Pass 0 for no audio.</param>
/// <param name="channelCount">Audio channel count. Pass 0 for no audio.</param>
/// <param name="bitrate">Video bitrate in bits per second.</param>
WEBMRecorder (int width, int height, float frameRate, int sampleRate = ..., int channelCaount = ..., int bitrate = ...);
The WEBMRecorder can be created to record video with optional audio. To record video only, simply provide the video width, video height, and video frameRate.
// Record video only at 720p30
var recorder = new WEBMRecorder(1280, 720, 60);
To record video with audio, you will provide the audio format along with the video format. The audio format comprises of the sampleRate and channelCount.
// Record 480p video with 24KHz mono audio
var recorder = new WEBMRecorder(640, 480, 30, 24000, 1);

/// <summary>
/// Video size.
/// </summary>
(int width, int height) frameSize { get; }
Refer to the Frame Size section of the IMediaRecorder interface for more information.

/// <summary>
/// Commit a video pixel buffer for encoding.
/// The pixel buffer MUST have an RGBA8888 pixel layout.
/// </summary>
/// <param name="pixelBuffer">Pixel buffer containing video frame to commit.</param>
/// <param name="timestamp">Pixel buffer timestamp in nanoseconds.</param>
void CommitFrame<T> (T[] pixelBuffer, long timestamp) where T : struct;
Refer to the Committing Video Frames section of the IMediaRecorder interface for more information.

/// <summary>
/// Commit an audio sample buffer for encoding.
/// </summary>
/// <param name="sampleBuffer">Linear PCM audio sample buffer, interleaved by channel.</param>
/// <param name="timestamp">Sample buffer timestamp in nanoseconds.</param>
void CommitSamples (float[] sampleBuffer, long timestamp);
Refer to the Committing Audio Frames section of the IMediaRecorder interface for more information.

/// <summary>
/// Finish writing and return the path to the recorded media file.
/// </summary>
Task<string> FinishWriting ();
Refer to the Finishing Recording section of the IMediaRecorder interface for more information.
Copy link
On this page
Creating the Recorder
Video Size
Committing Video Frames
Committing Audio Frames
Finishing Recording