NatCorder
Search…
WEBMRecorder
class NatSuite.Recorders.WEBMRecorder : IMediaRecorder
WebCorder provides the WEBMRecorder for recording *.webm video files. This is currently the most widely supported video format on web.
The WEBMRecorder uses the VP8 codec for video.

Creating the Recorder

1
/// <summary>
2
/// Create a WEBM recorder.
3
/// </summary>
4
/// <param name="width">Video width.</param>
5
/// <param name="height">Video height.</param>
6
/// <param name="frameRate">Video frame rate.</param>
7
/// <param name="sampleRate">Audio sample rate. Pass 0 for no audio.</param>
8
/// <param name="channelCount">Audio channel count. Pass 0 for no audio.</param>
9
/// <param name="bitrate">Video bitrate in bits per second.</param>
10
WEBMRecorder (int width, int height, float frameRate, int sampleRate = ..., int channelCaount = ..., int bitrate = ...);
Copied!
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.
1
// Record video only at 720p30
2
var recorder = new WEBMRecorder(1280, 720, 60);
Copied!
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.
1
// Record 480p video with 24KHz mono audio
2
var recorder = new WEBMRecorder(640, 480, 30, 24000, 1);
Copied!

Video Size

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

Committing Video Frames

1
/// <summary>
2
/// Commit a video pixel buffer for encoding.
3
/// The pixel buffer MUST have an RGBA8888 pixel layout.
4
/// </summary>
5
/// <param name="pixelBuffer">Pixel buffer containing video frame to commit.</param>
6
/// <param name="timestamp">Not used.</param>
7
void CommitFrame<T> (T[] pixelBuffer, long timestamp = default) where T : struct;
Copied!
Refer to the Committing Video Frames section of the IMediaRecorder interface for more information.
The WEBMRecorder does not use the timestamps on committed video frames. Instead, it relies on the frameRate provided to the constructor.

Committing Audio Frames

1
/// <summary>
2
/// Commit an audio sample buffer for encoding.
3
/// </summary>
4
/// <param name="sampleBuffer">Linear PCM audio sample buffer, interleaved by channel.</param>
5
/// <param name="timestamp">Not used.</param>
6
void CommitSamples (float[] sampleBuffer, long timestamp = default);
Copied!
Refer to the Committing Audio Frames section of the IMediaRecorder interface for more information.
The WEBMRecorder does not use the timestamps on committed audio frames. Instead, it relies on thesampleRate provided to the constructor.

Finishing Recording

1
/// <summary>
2
/// Finish writing and return the path to the recorded media file.
3
/// </summary>
4
Task<string> FinishWriting ();
Copied!
Refer to the Finishing Recording section of the IMediaRecorder interface for more information.
The returned path will point to a blob in the browser's memory. As such, it will look something like"blob:http://...".
Last modified 1yr ago