media
media copied to clipboard
Media3 Transformer: Support `mediaStoreOutputOptions ` when calling `transformer.start()`
When working with Media3 Transformer, a transformation on a video is started by transformer.start(editedMediaItem, outputPath), but it would be more convenient if transformer.start() was also able to take in MediaStoreOutputOptions instead of a String outputPath.
This would be similar to how CameraX starts video recordings (https://developer.android.com/training/camerax/video-capture#configure-and-create-recording):
// 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)
If this request is not prioritized, it would be useful to know what the best way is to work with a filepath and MediaStoreOutput. As in, how can the app take the file path and feed that into MediaStore so that the newly created file is also stored with the other media items of the app?