android / camera-samples

Multiple samples showing the best practices in camera APIs on Android.
Apache License 2.0
4.89k stars 2.31k forks source link

Invalid after MediaStoreOutputOptions is set #542

Open PeOS-China opened 1 year ago

PeOS-China commented 1 year ago

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}")
                }

        }
GauravCreed commented 4 months ago

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

Thanks (_)