Tanoda
|
NatCorder is a lightweight, easy-to-use, native video recording API for iOS, Android, macOS, and Windows. NatCorder comes with a rich featureset including:
NatCorder provides a simple recording API with instances of the IMediaRecorder
interface. NatCorder works by encoding video and audio frames on demand. To start recording, simply create a recorder corresponding to the media type you want to record:
Once you create a recorder, you then commit frames to it. You can commit video and audio frames to these recorders. These committed frames are then encoded into a media file. When committing frames, you must provide the frame data with a corresponding timestamp. The spacing between timestamps determine the final frame rate of the recording.
NatCorder records video using pixel buffers. The pixel buffers must be 32-bit per pixel, RGBA encoding (TextureFormat.RGBA32
). The managed type of the pixel buffer is entirely flexible. As a result, you can commit a Color32[]
, a byte[]
, an int[]
, or any struct array that can be interpreted as an RGBA32
pixel buffer.
When committing a pixel buffer for encoding, you will need to provide a corresponding timestamp. For this purpose, you can use implementations of the IClock
interface. Here is an example illustrating recording a WebCamTexture
:
NatCorder records audio provided as interleaved PCM sample buffers (float[]
). Similar to recording video frames, you will call the IMediaRecorder.CommitSamples
method, passing in a sample buffer and a corresponding timestamp. It is important that the timestamps synchronize with those of video, so it is recommended to use the same IClock
for generating video and audio timestamps. Below is an example illustrating recording game audio using Unity's OnAudioFilterRead
callback:
In most cases, you will likely just want to record a game camera optionally with game audio. To do so, you can use NatCorder's recorder Inputs
. A recorder Input
is a lightweight utility class that eases out the process of recording some aspect of a Unity application. NatCorder comes with two recorder inputs: CameraInput
and AudioInput
. You can create your own recorder inputs to do more interesting things like add a watermark to the video, or retime the video. Here is a simple example showing recording a game camera:
Thank you very much!