Recording and Snapshots

Note: The camera should have already started streaming LiveView before making any interactions


Start Recording

To start recording the live stream, The following can be used:

  • size (optional): The size of the recorded video. Pass nil to keep the native resolution.
  • fileName (optional): Base name. The file is written to the temporary directory as <fileName>_<viewIndex>.mov; a timestamp is used when nil.
liveViewObject.startRecording(size: CGSize?, fileName: String? = nil)

The isRecordingLiveView property can be read to check whether a recording is in progress.


Stop Recording

To stop the recording, The following can be used:

  • completion (required): Returns the path of the recorded file on success. Called once per rendered view — on a multi-sensor camera expect one result per view.
liveViewObject.stopRecording { result in
    switch result {
    case .success(let path):
        // Path of the recorded file
    case .failure(let error):
        // Handle the error
    }
}

Capture a Snapshot

To capture a still image from the live stream, The following can be used:

  • size (optional): The size of the captured image. Pass nil to keep the native resolution.
  • snapshot (required): (UIImage?) -> Void, called once per view; nil if the frame could not be converted.
liveViewObject.captureSnapshot(size: CGSize?) { image in
    // Captured image
}

Capture from a specific view

On a multi sensor camera each lens renders into its own IVVideoView. captureSnapshot and stopRecording are also available on the view itself. A recording can only be started from the model, and stopping it from a single view leaves isRecordingLiveView (and the other views’ recordings) untouched:

let videoView = liveViewObject.remoteViews.first

videoView?.captureSnapshot(size: CGSize?) { image in
    // Captured image
}

videoView?.stopRecording { result in
    // Path of the recorded file, or an error
}