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);
- Set the
sampleRate
toAudioSettings.outputSampleRate.
- Set the
channelCount
to(int)AudioSettings.speakerMode
.
/// <summary>
/// Video size.
/// </summary>
(int width, int height) frameSize { get; }
/// <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;
/// <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);
/// <summary>
/// Finish writing and return the path to the recorded media file.
/// </summary>
Task<string> FinishWriting ();
Last modified 6mo ago