camera-samples icon indicating copy to clipboard operation
camera-samples copied to clipboard

Invalid after MediaStoreOutputOptions is set

Open PeOS-China opened this issue 1 year ago • 1 comments

The format MP4 and name of the captured video are set through MediaStoreOutputOptions, but the format of the video captured by CameraX is 3gp, and it is not the name of the setting My Android system is AndroidP, SDK is 28,CameraX Version is 1.2.2


videoCapture?.let { vc ->
            val name = "Video_${System.currentTimeMillis()}.mp4"
            val contentValues = ContentValues().apply {
                put(MediaStore.Video.Media.DISPLAY_NAME, name)
                put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4")
                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
                    put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/Videos")
                }
            }
            val mediaStoreOutput = MediaStoreOutputOptions.Builder(
                requireActivity().contentResolver, MediaStore.Video.Media.EXTERNAL_CONTENT_URI
            )
                .setContentValues(contentValues)
                .build()

            recording = vc.output
                .prepareRecording(requireContext(), mediaStoreOutput)
                .withAudioEnabled()
                .start(
                    ContextCompat.getMainExecutor(requireContext())
                ) {
                    Logger.d("testCamera", "camera recording event: ${it.recordingStats}")
                }

        }

PeOS-China avatar May 18 '23 08:05 PeOS-China

@PeOS-China have you found solution for this? if yes then pls share with us.

Thanks (_)

GauravCreed avatar Feb 24 '24 06:02 GauravCreed