--- id: recording-videos title: Recording Videos sidebar_label: Recording Videos --- import useBaseUrl from '@docusaurus/useBaseUrl'
## Camera Functions The Camera provides certain functions which are available through a [ref object](https://reactjs.org/docs/refs-and-the-dom.html): ```tsx function App() { const camera = useRef(null) // ... return ( ) } ``` To use these functions, you need to wait until the [`onInitialized`](/docs/api/interfaces/CameraProps#oninitialized) event has been fired. ## Recording Videos To start a video recording you first have to enable video capture: ```tsx ``` Then, simply use the Camera's [`startRecording(...)`](/docs/api/classes/Camera#startrecording) function: ```ts camera.current.startRecording({ onRecordingFinished: (video) => console.log(video), onRecordingError: (error) => console.error(error) }) ``` You can customize capture options such as [video codec](/docs/api/interfaces/RecordVideoOptions#videoCodec), [video bit-rate](/docs/api/interfaces/RecordVideoOptions#videoBitRate), [file type](/docs/api/interfaces/RecordVideoOptions#fileType), [enable flash](/docs/api/interfaces/RecordVideoOptions#flash) and more using the [`RecordVideoOptions`](/docs/api/interfaces/RecordVideoOptions) parameter. For any error that occured _while recording the video_, the `onRecordingError` callback will be invoked with a [`CaptureError`](/docs/api/classes/CameraCaptureError) and the recording is therefore cancelled. To stop the video recording, you can call [`stopRecording(...)`](/docs/api/classes/Camera#stoprecording): ```ts await camera.current.stopRecording() ``` Once a recording has been stopped, the `onRecordingFinished` callback passed to the [`stopRecording(...)`](/docs/api/classes/Camera#stoprecording) function will be invoked with a [`VideoFile`](/docs/api/interfaces/VideoFile) which you can then use to display in a [`