HomeGuidesAPI ReferenceChangelogDiscussions
Hire a ReactVision Expert 🛠️Launch Studio 🖥️Sponsor on GitHub ❤️Log In
Guides

AR Session Recording

AR Session Recording

Capture an AR session to local storage — camera passthrough + raw IMU + ground-truth pose — for offline analysis (e.g. tinyvio / reactviro_validate_recording). This is not screen recording.

Not the same as startVideoRecording / stopVideoRecording, or ViroCameraTexture's startRecording. Those capture rendered / camera-texture video. Session recording keeps three separate streams a visual-inertial engine needs to replay the session offline.

Available since ViroReact 2.58.0. Documented here as part of the 3.0 docs catch-up.

Quick start

const { success, error } = await sceneNavigator.startRecording(outputDir);
// ...walk the space...
const result = await sceneNavigator.stopRecording(); // 3.1.0+: ViroRecordingResult
const status: ViroRecordingStatus = await sceneNavigator.getRecordingStatus(); // "None" | "Recording" | "IOError" | "Unsupported"

outputDir should be a plain filesystem path (not a file:// URI). After stop it contains video.mp4 and session.jsonl, plus depth/ when depth was recorded (3.1.0+).

📘

Recording a place for VPS? From 3.1.0 a recording can be uploaded to ReactVision Spatial with uploadScanRecording. See Using Advanced VPS in Your App.

API

MethodDescription
startRecording(outputDir, options?)Starts capture. Returns { success, error? }. 3.1.0+: { depth: true } also records depth (see below).
stopRecording()Finalises files. No-op if nothing is recording. 3.1.0+: resolves to a ViroRecordingResult once every file is complete: { success, error?, durationSec, frames, depthFrames, gpsFixes, bytes? }.
isRecordingSupported({ depth? })3.1.0+. Whether the device can record, and record depth. On Android it answers false until the AR session has started, so ask after the first tracking update.
getRecordingStatus()ViroRecordingStatus: "None" | "Recording" | "IOError" | "Unsupported", the same on iOS and Android from 3.0.3.

Depth (3.1.0+)

Set depthCaptureEnabled on ViroARSceneNavigator when it mounts, then call startRecording(outputDir, { depth: true }). With LiDAR on iOS or the ARCore Depth API on Android, the recording gains:

  • depth/NNNNNN.png: 16-bit greyscale depth in millimetres, at most one every 100 ms
  • depth/NNNNNN_c.png: 8-bit confidence
  • a depth line per frame in session.jsonl, and "depth": true in its header

Switching depth on reconfigures the AR session, which can make tracking jump, so it is not done when recording starts. A recording started with depth: true without depthCaptureEnabled, or on a device that cannot measure depth, is made without depth and its header says "depth": false. On Android the depth is ARCore's smoothed depth with its raw confidence. ViroRecordingOptions and ViroRecordingResult are exported.

Platform support

PlatformStatus
iOS✅
Android✅
Web / visionOS / Quest❌ — getRecordingStatus() returns "Unsupported"

Audio

Session recordings have no audio track, and startRecording needs no microphone permission. The microphone belongs to startVideoRecording: on Android it fails with error 1 when RECORD_AUDIO is denied, and on iOS it records without sound.

⚠️

Correction

The 3.0.3 notes below said startRecording rejects without RECORD_AUDIO on Android and that recordings carry an audio track on iOS. Checked against the 3.1.0 source, the microphone check and the audio track are in startVideoRecording, not the session recorder.

Changes in 3.0.3

  • Same status strings on both platforms. getRecordingStatus() answers "None", "Recording", "IOError" or "Unsupported" on Android too, typed by the exported ViroRecordingStatus. Android used to return the Java enum names (NONE, RECORDING, IO_ERROR, UNSUPPORTED), so update any code that matched them.
  • Microphone permission on Android. startRecording without RECORD_AUDIO now rejects instead of hanging. Request the microphone permission before you start.
  • iOS. Camera recordings carry an audio track, and every recording promise settles (virocore 3.0.3).

Getting files off the device

On iOS, enable Files-app access (UIFileSharingEnabled + LSSupportsOpeningDocumentsInPlace) and/or share immediately with expo-sharing. Android app-external paths are reachable via adb pull or a file manager.

Related