API Reference
RecordOptions Full reference for recording configuration options
RecordOptions is the configuration object passed to recorder.record(). It controls the output file, encoding parameters, and frame callbacks.
Option Type Default Description outputstringRequired Absolute path for the output video file fpsnumberRequired Frames per second totalFramesnumber- Total number of frames to capture. When omitted, recording continues until stop() is called (event-driven mode). onFrame(info: FrameInfo) => void | Promise<void>- Called before each frame is captured. Use this to update the RecordingView's content for the next frame. The library waits for the returned promise before capturing. onProgress(info: RecordProgress) => void- Called after each frame is captured and encoded. Use this for progress indicators. widthnumberView's pixel width Output video width in pixels heightnumberView's pixel height Output video height in pixels codecVideoCodec"hevc"Video codec to use bitratenumberAuto-scaled by resolution Target bitrate in bits/second qualitynumber- Encoding quality hint, 0.0 (smallest file) to 1.0 (best quality) keyFrameIntervalnumber2Seconds between keyframes optimizeForNetworkbooleantrueMove the moov atom to the front of the file for progressive playback. iOS only; ignored on Android. audioFileAudioFileOptions- Mux an audio file into the video natively. Supports WAV, MP3, AAC, M4A. Cannot be combined with mixAudio. mixAudio(info: AudioMixInfo) => Float32Array | null- Per-frame audio callback. Return interleaved Float32 samples, or null for silence. Cannot be combined with audioFile. signalAbortSignal- Cancel the recording. The record() promise rejects with AbortError and the partial file is deleted.
type VideoCodec = "h264" | "hevc" | "hevcWithAlpha" ;
Value Description "h264"H.264/AVC. Widest compatibility. "hevc"H.265/HEVC. Better compression at the same quality. Default. On Android, if the device lacks a hardware HEVC encoder, the library silently falls back to H.264. "hevcWithAlpha"HEVC with alpha channel support. iOS only.
Property Type Description frameIndexnumberCurrent frame index (0-based) totalFramesnumber | undefinedTotal frames to capture, or undefined in event-driven mode
Property Type Description framesEncodednumberNumber of frames encoded so far totalFramesnumber | undefinedTotal frames to capture, or undefined in event-driven mode
Property Type Default Description pathstringRequired Absolute path to the audio file startTimenumber0Start time offset in seconds
Property Type Description frameIndexnumberCurrent frame index samplesNeedednumberNumber of audio frames for this video frame. Return samplesNeeded * channels interleaved values. sampleRatenumberAudio sample rate (44100) channelsnumberNumber of audio channels (1)
Exported class thrown when a recording is cancelled via signal. Use instanceof AbortError to distinguish cancellations from other errors.
import { AbortError } from "react-native-view-recorder" ;
const controller = new AbortController ();
try {
await recorder. record ({
output: "/path/to/video.mp4" ,
fps: 30 ,
totalFrames: 300 ,
signal: controller.signal,
onFrame : async ({ frameIndex }) => setFrame (frameIndex),
});
} catch (error) {
if (error instanceof AbortError ) {
console. log ( "Recording cancelled" );
}
}
// Cancel from elsewhere:
controller. abort ();
const outputPath = await recorder. record ({
output: FileSystem.cacheDirectory + "recording.mp4" ,
fps: 60 ,
totalFrames: 300 ,
width: 1080 ,
height: 1920 ,
codec: "hevc" ,
bitrate: 8_000_000 ,
quality: 0.9 ,
keyFrameInterval: 1 ,
optimizeForNetwork: true ,
onFrame : async ({ frameIndex , totalFrames }) => {
setAnimationProgress (frameIndex / totalFrames);
},
onProgress : ({ framesEncoded , totalFrames }) => {
setProgress (Math. round ((framesEncoded / totalFrames) * 100 ));
},
});