VideoRecorder PRO
VideoRecorder provides a programmable video recording session in Scripting.
It encapsulates camera selection, audio/video capture, encoding, pause/resume handling, zoom, focus, torch control, and final file writing.
This API is intended for custom camera interfaces, video capture utilities, and automated recording workflows.
Capabilities Overview
- Front and back camera support
- Explicit camera type selection (wide, ultra-wide, telephoto, etc.)
- Multiple frame rates (24 / 30 / 60 / 120)
- Optional audio recording
- Multiple system capture session presets
- Multiple video codecs (HEVC / H.264 / ProRes, etc.)
- Pause and resume during recording
- Independent focus and exposure control
- Zoom and smooth zoom (ramp) control
- Torch (flashlight) control
- Deterministic state machine with callbacks
- Explicit lifecycle management (
prepare / reset / dispose)
Type Definitions
CameraPosition
Represents the physical camera position.
CameraType
Represents the physical camera device type. Availability depends on the device hardware.
VideoRecorderState
State Semantics
VideoCaptureSessionPreset
Defines the capture session resolution preset.
VideoCodec
Specifies the video encoding format. Actual availability depends on system and hardware support.
VideoOrientation
Specifies the output video orientation.
Constructor
settings
Parameter Details
-
camera
positionCamera position. Defaults to"back".preferredTypesPreferred camera device types. If omitted, a suitable device is selected automatically based on position.
-
frameRate Target frame rate. Supported values: 24, 30, 60, 120. Defaults to 30. Actual frame rate depends on device capability.
-
audioEnabled Indicates whether audio is recorded. Defaults to
true. -
sessionPreset Capture session resolution preset. Defaults to
"high". -
videoCodec Video encoding format. Defaults to
"hevc". -
videoBitRate Average video bit rate in bits per second. If omitted, the system selects an appropriate value.
-
orientation Output video orientation. Defaults to
"portrait". -
mirrorFrontCamera Indicates whether the front camera output is mirrored. Defaults to
true. Only applies to the front camera.
Read-Only Properties
minZoomFactor
Minimum supported zoom factor for the active device.
maxZoomFactor
Maximum supported zoom factor for the active device.
currentZoomFactor
Current zoom factor.
displayZoomFactor
Zoom factor displayed to the user.
hasTorch
Indicates whether the active camera supports a torch.
torchMode
Current torch mode.
State and Callbacks
state
Represents the current state of the recorder.
onStateChanged
Invoked whenever the recorder state changes.
-
When
state === "failed"detailscontains an error description. -
When
state === "finished"detailscontains the full output file path.
Methods
prepare()
Prepares the recorder by configuring the camera session and audio/video pipelines.
Usage Constraints
- Must be called before
startRecording - Transitions state to
readyon success - Transitions to
failedon error
startRecording(toPath)
Starts video recording.
Parameters
- toPath Full file path where the video will be saved.
Usage Constraints
- Only valid in the
readystate - Transitions state to
recording
pauseRecording()
Pauses the ongoing recording.
Usage Constraints
- Only valid in the
recordingstate - Transitions state to
paused - Timeline is compacted without introducing blank segments
resumeRecording()
Resumes a paused recording.
Usage Constraints
- Only valid in the
pausedstate - Transitions state back to
recording
stopRecording()
Stops recording and finalizes the output file.
Behavior
- Transitions state to
finishing - Transitions to
finishedafter file writing completes - Final file path is delivered via
onStateChanged
reset()
Resets the recorder state to allow a new recording session.
Intended Use
- After a completed recording
- After a failed recording
Behavior
- Transitions state back to
idle preparemay be called again
setTorchMode()
Sets the torch mode for the active camera.
setFocusPoint()
Sets the focus point.
- Coordinates are normalized in the range
0.0 ~ 1.0 (0,0)represents the top-left corner(1,1)represents the bottom-right corner
setExposurePoint()
Sets the exposure point using the same coordinate system as focus.
resetFocus()
Restores automatic focus mode.
resetExposure()
Restores automatic exposure mode.
setZoomFactor()
Immediately sets the zoom factor.
- Value must be within
minZoomFactorandmaxZoomFactor
rampZoomFactor()
Smoothly transitions the zoom factor.
toFactorspecifies the target zoom factorratespecifies the transition speed in powers of two per second
resetZoom()
Resets the zoom factor to the default value (typically 1.0).
dispose()
Releases all resources and destroys the recorder.
Usage Constraints
- The instance cannot be used after disposal
- Releases camera, audio, and system resources
- Should be called when the recording lifecycle ends
Typical Usage Flow
Usage Guidelines
- Always observe
onStateChangedto track state transitions - Do not start recording before calling
prepare - Call
resetbefore reusing the same instance for another recording - Call
disposewhen the recorder is no longer needed
