Recorder Inputs
Simplifying Common Recording Workflows
In most use cases, you will likely only want to record from a game camera (or several game cameras) and/or an audio source in your scene. Instead of writing boilerplate code to extract raw pixel buffers and sample buffers from these game objects, NatCorder provides a set of helper classes which automatically handle this process. These are called Recorder Inputs.
Recording the Screen
NatCorder provides the ScreenInput
recorder input for recording video frames from the screen:
When finishing recording, dispose the ScreenInput
before stopping the recorder.
You must dispose all recorder inputs before finishing the recorder, not after.
Recording Game Cameras
NatCorder provides the CameraInput
recorder input for recording one or more game cameras.
When finishing recording, dispose the CameraInput
before stopping the recorder.
Recording Game Audio
For recording game audio, either from a Unity AudioSource
or AudioListener
, NatCorder provides the AudioInput
recorder input.
Similarly, when finishing recording make sure to dispose the input before stopping the recorder.
Best Practices
There are a few things to note when recording with recorder inputs.
Recording Timestamps
Most recorders expect audio and video frames to be committed with a corresponding timestamp, specified in nanoseconds. NatCorder provides implementations of the IClock
interface to simplify the process of calculating timestamps.
All recorder inputs take in a recorder and a clock. The clock is used to generate timestamps as frames are being sent to recorder by the recorder input. When recording both video and audio frames, it is highly recommended to share the same clock between your camera input and audio input. This will guarantee that frames in the recording are synchronized in time, preventing issues like drift.
Using Multiple Inputs
It is possible to use multiple recorder inputs during a single recording session. A typical use case is when recording video from a game camera along with audio from the game.
For a given recorder, do not create multiple recorder inputs that commit the same kind of media. For example, do not create several camera inputs.
Mixed Recording
It is possible to mix manual recording with recorder inputs. The constraint, as mentioned above, is that you must use one method for video and the other for audio. Below is a typical use case that involves mixed recording:
With the above method, we must manually commit video frames.
Note that we share the same clock between our manual recording and our recorder input.
And when we're done recording, we dispose the recorder input.
Last updated