I am following the official documentation to capture a video with CameraX, and I want to avoid saving the captured video in the gallery.
For now I am working on this part of the documentation code:
// Create MediaStoreOutputOptions for our recorder
val name = "CameraX-recording-" +
SimpleDateFormat(FILENAME_FORMAT, Locale.US)
.format(System.currentTimeMillis()) + ".mp4"
val contentValues = ContentValues().apply {
put(MediaStore.Video.Media.DISPLAY_NAME, name)
}
val mediaStoreOutput = MediaStoreOutputOptions.Builder(this.contentResolver,
MediaStore.Video.Media.EXTERNAL_CONTENT_URI)
.setContentValues(contentValues)
.build()
// 2. Configure Recorder and Start recording to the mediaStoreOutput.
val recording = videoCapture.output
.prepareRecording(context, mediaStoreOutput)
.withAudioEnabled()
.start(ContextCompat.getMainExecutor(this), captureListener)
I noticed that prepaeRecording()
can take FileOutputOptions instead of MediaStoreOutput
, so I thought it could be where should I work but I have not found any example with FileOutputOptions and CameraX, and also I want it to work with the scoped permissions.
Is that possible? and can you help with an example to avoid saving the video to the gallery?
/data/data/package_name
one but is there a limitation for/storage/emulated/0/Android/data/package_name
too? – Burschenschaft