Comment on page
Fundamentals
What You Should Know
NatCorder provides all recording functionality with implementations of a single interface:
IMediaRecorder
. At the highest level, NatCorder works by encoding video and audio frames on-demand. As a result, recording always follows three steps:The first step is to start a recording session by creating a recorder.
// These are the currently supported recorders
var gifRecorder = new GIFRecorder(...);
var mp4Recorder = new MP4Recorder(...);
var hevcRecorder = new HEVCRecorder(...);
var jpgRecorder = new JPGRecorder(...);
var wavRecorder = new WAVRecorder(...);
var webmRecorder = new WEBMRecorder(...);
There is no defined limit on the number of simultaneous recording sessions, but the actual limit will vary by device.
Once you have created a recorder, you will commit video and/or audio frames to the recorder.
When committing video frames, the recorder always expects a pixel buffer with an
RGBA8888
layout in memory. You will use the CommitFrame
method to commit video frames.// Say I have a texture
var texture = new Texture2D(...) or new WebCamTexture(...);
// I can commit its pixel data for recording
recorder.CommitFrame(texture.GetPixels32(), ...);
The
CommitFrame
method takes in any managed numeric array which can be interpreted as a pixel buffer.// So you can commit a byte array
var byteBuffer = new byte[...];
recorder.CommitFrame(byteBuffer, ...);
// Or an int array
var intBuffer = new int[...];
recorder.CommitFrame(intBuffer, ...);
When committing audio frames, the recorder always expects a single precision floating point (
float
) linear PCM sample buffer, interleaved by channel. You will use the CommitSamples
method to commit audio frames.var sampleBuffer = new float[...];
recorder.CommitSamples(sampleBuffer, ...);
var path = await recorder.FinishWriting();
The recorder will finish its operations, cleanup any resources, then return a path to the recorded video.
Last modified 1yr ago