Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,15 @@ class HybridVideoOutput(
@SuppressLint("MissingPermission")
override fun createRecorder(settings: RecorderSettings): Promise<HybridRecorderSpec> {
return Promise.async {
// Create .mp4 file in temp directory
val file = File.createTempFile("VisionCamera_", "mp4")
val file =
if (settings.filePath != null) {
File(settings.filePath)
} else {
// Create .mp4 file in temp directory
File.createTempFile("VisionCamera_", "mp4")
}
// Create all parent directories if they don't exist yet.
file.parentFile?.mkdirs()
Comment thread
mrousavy marked this conversation as resolved.

// Prepare output options
val fileOutputOptions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ class HybridVideoRecorder: HybridRecorderSpec {
) throws {
self.videoOutput = videoOutput
self.queue = queue
self.fileURL = try URL.createTempURL(fileType: fileType.toUTType())
if let customFilePath = settings.filePath {
self.fileURL = URL(fileURLWithPath: customFilePath)
} else {
self.fileURL = try URL.createTempURL(fileType: fileType.toUTType())
}
Comment thread
mrousavy marked this conversation as resolved.
// Create all parent directories if they don't exist yet.
try FileManager.default.createDirectory(
Comment thread
mrousavy marked this conversation as resolved.
at: self.fileURL.deletingLastPathComponent(),
withIntermediateDirectories: true
)
self.settings = settings
super.init()
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ export interface RecorderSettings {
* into the video metadata using the ISO-6709 standard.
*/
location?: Location
/**
* The absolute path (including file name and extension) where
* the recording file should be written to, or `undefined` to
* create a file in the device's temporary directory.
*
* All parent directories in this {@linkcode filePath} will
* be automatically created if they do not yet exist.
*
* @default undefined
*/
Comment thread
mrousavy marked this conversation as resolved.
filePath?: string
/**
* If set, the recording automatically stops once it reaches
* this duration, in seconds.
Expand Down Expand Up @@ -210,8 +221,9 @@ export interface CameraVideoOutput extends CameraOutput {
* Creates and prepares a new {@linkcode Recorder}
* instance with the given {@linkcode RecorderSettings}.
*
* The {@linkcode Recorder} will record to a temporary
* file, and can only record once.
* The {@linkcode Recorder} will record to the configured
* file path, or to a temporary file if no path was provided.
* It can only record once.
*
* If you want to create a second recording,
* you must create a new {@linkcode Recorder}.
Expand Down
Loading