2023-09-26 03:39:17 -06:00
|
|
|
import type { CameraCaptureError } from './CameraError'
|
|
|
|
import type { TemporaryFile } from './TemporaryFile'
|
2021-02-19 08:07:53 -07:00
|
|
|
|
|
|
|
export interface RecordVideoOptions {
|
|
|
|
/**
|
|
|
|
* Set the video flash mode. Natively, this just enables the torch while recording.
|
|
|
|
*/
|
2023-10-05 08:40:15 -06:00
|
|
|
flash?: 'on' | 'off'
|
2021-05-06 06:11:55 -06:00
|
|
|
/**
|
2023-08-21 04:50:14 -06:00
|
|
|
* Specifies the output file type to record videos into.
|
2021-05-06 06:11:55 -06:00
|
|
|
*/
|
2023-09-26 03:39:17 -06:00
|
|
|
fileType?: 'mov' | 'mp4'
|
2021-02-19 08:07:53 -07:00
|
|
|
/**
|
|
|
|
* Called when there was an unexpected runtime error while recording the video.
|
|
|
|
*/
|
2023-09-26 03:39:17 -06:00
|
|
|
onRecordingError: (error: CameraCaptureError) => void
|
2021-02-19 08:07:53 -07:00
|
|
|
/**
|
|
|
|
* Called when the recording has been successfully saved to file.
|
|
|
|
*/
|
2023-09-26 03:39:17 -06:00
|
|
|
onRecordingFinished: (video: VideoFile) => void
|
2021-12-30 02:47:23 -07:00
|
|
|
/**
|
2023-08-21 04:50:14 -06:00
|
|
|
* The Video Codec to record in.
|
|
|
|
* - `h264`: Widely supported, but might be less efficient, especially with larger sizes or framerates.
|
2023-11-27 09:29:25 -07:00
|
|
|
* - `h265`: The HEVC (High-Efficient-Video-Codec) for higher efficient video recordings. Results in up to 50% smaller file-sizes.
|
2021-12-30 02:47:23 -07:00
|
|
|
*/
|
2023-09-26 03:39:17 -06:00
|
|
|
videoCodec?: 'h264' | 'h265'
|
2023-09-29 07:27:09 -06:00
|
|
|
/**
|
|
|
|
* The bit-rate for encoding the video into a file, in Mbps (Megabits per second).
|
|
|
|
*
|
2023-11-27 09:29:25 -07:00
|
|
|
* Bit-rate is dependant on various factors such as resolution, FPS, pixel format (whether it's 10 bit HDR or not), and video codec.
|
2023-09-29 07:27:09 -06:00
|
|
|
*
|
2023-11-27 09:29:25 -07:00
|
|
|
* By default, it will be calculated by the hardware encoder, which takes all those factors into account.
|
|
|
|
*
|
|
|
|
* * `extra-low`: 40% lower than whatever the hardware encoder recommends.
|
|
|
|
* * `low`: 20% lower than whatever the hardware encoder recommends.
|
|
|
|
* * `normal`: The recommended value by the hardware encoder.
|
|
|
|
* * `high`: 20% higher than whatever the hardware encoder recommends.
|
|
|
|
* * `extra-high`: 40% higher than whatever the hardware encoder recommends.
|
|
|
|
* * `number`: Any custom number for the bit-rate, in Mbps.
|
2023-09-29 07:27:09 -06:00
|
|
|
*
|
|
|
|
* @default 'normal'
|
|
|
|
*/
|
2023-11-27 09:29:25 -07:00
|
|
|
videoBitRate?: 'extra-low' | 'low' | 'normal' | 'high' | 'extra-high' | number
|
2021-02-19 08:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a Video taken by the Camera written to the local filesystem.
|
2021-03-08 10:21:30 -07:00
|
|
|
*
|
2021-03-08 10:51:53 -07:00
|
|
|
* Related: {@linkcode Camera.startRecording | Camera.startRecording()}, {@linkcode Camera.stopRecording | Camera.stopRecording()}
|
2021-02-19 08:07:53 -07:00
|
|
|
*/
|
2021-03-08 09:51:47 -07:00
|
|
|
export interface VideoFile extends TemporaryFile {
|
|
|
|
/**
|
|
|
|
* Represents the duration of the video, in seconds.
|
|
|
|
*/
|
2023-09-26 03:39:17 -06:00
|
|
|
duration: number
|
2023-12-12 08:43:57 -07:00
|
|
|
/**
|
|
|
|
* The width of the video, in pixels.
|
|
|
|
*/
|
|
|
|
width: number
|
|
|
|
/**
|
|
|
|
* The height of the video, in pixels.
|
|
|
|
*/
|
|
|
|
height: number
|
2021-03-08 09:51:47 -07:00
|
|
|
}
|