admin管理员组

文章数量:1416051

I am only encountering this issue on a Redmi Note 11 Pro 5G, I am not sure why but the Camera support level is LEVEL_3 if it matters.

I get the error below and camera shows me a black preview

Stream configuration failed due to: endConfigure:667: Camera 0: Unsupported set of inputs/outputs provided
2025-02-03 12:14:49.525  6817-7967  CameraCaptureSession      E  Session 0: Failed to create capture session; configuration failed

Stack trace:

025-02-03 12:14:49.000  6817-7688  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.000  6817-7688  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.003  6817-7688  libc                      W  Access denied finding property "persist.vendor.camera.privapp.list"
2025-02-03 12:14:49.004  6817-7688  CameraExtImplXiaoMi       D  initCameraDevice: 0
2025-02-03 12:14:49.020  6817-7688  CameraManager             I  Open camera top activityName is <activity name>
2025-02-03 12:14:49.040  6817-7402  CameraManagerGlobal       E  Camera 4 is not available. Ignore physical camera status change
2025-02-03 12:14:49.172  6817-7402  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.172  6817-7402  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.172  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.173  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.173  6817-7402  CameraManagerGlobal       W  ignore the torch status update of camera: 2
2025-02-03 12:14:49.173  6817-7402  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.173  6817-7402  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.173  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.173  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.174  6817-7402  CameraManagerGlobal       W  ignore the torch status update of camera: 3
2025-02-03 12:14:49.174  6817-7402  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.174  6817-7402  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.174  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.174  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.174  6817-7402  CameraManagerGlobal       W  ignore the torch status update of camera: 4
2025-02-03 12:14:49.175  6817-6835  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.175  6817-6835  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.175  6817-6835  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.175  6817-6835  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.176  6817-6835  CameraManagerGlobal       W  ignore the torch status update of camera: 5
2025-02-03 12:14:49.314  6817-7688  BpBinder                  W  PerfMonitor binderTransact :  time=294ms interface=android.hardware.ICameraService code=4
2025-02-03 12:14:49.320  6817-7967  Camera2Controller         D  FPS range is [12, 30]
2025-02-03 12:14:49.409  6817-7967  CameraDevice-JV-0         D  waitUntilIdle: E. id = 0
2025-02-03 12:14:49.410  6817-7967  CameraDevice-JV-0         D  waitUntilIdle: X
2025-02-03 12:14:49.525  6817-7967  CameraDevice-JV-0         W  Stream configuration failed due to: endConfigure:667: Camera 0: Unsupported set of inputs/outputs provided
2025-02-03 12:14:49.525  6817-7967  CameraCaptureSession      E  Session 0: Failed to create capture session; configuration failed
2025-02-03 12:14:49.526  6817-7967  Camera2Con...iewSession   D  Configuration Failed

Relevant code, you may need to setup a few other things if you want to run it. The error goes away if I remove the recorderSurface from the list of surfaces when creating the capture session, but I cannot record then. It only happens for this specific phone so far.

private var recorderSurface: Surface? = null
private var previewReader: ImageReader? = null
private var captureReader: ImageReader? = null
private var cameraThread: HandlerThread? = null
private var cameraHandler: Handler? = null
private var mediaRecorder: MediaRecorder? = null

previewReader = ImageReader.newInstance(1920, 1080, ImageFormat.YUV_420_888, 5)
captureReader = ImageReader.newInstance(1920, 1080, ImageFormat.YUV_420_888, 5)
 
cameraThread = HandlerThread("Camera").also { it.start() }
cameraHandler = Handler(cameraThread.looper)

private fun createRecordRequest() {

    val recorderSurface = MediaCodec.createPersistentInputSurface()
    mediaRecorder = MediaRecorder().apply {
        setVideoSource(MediaRecorder.VideoSource.SURFACE)
        setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
        setOutputFile(context.cacheDir.path + "/file.mp4")
        setVideoEncoder(MediaRecorder.VideoEncoder.HEVC)
        setVideoEncodingBitRate(2_000_000)
        setVideoFrameRate(30)
        setVideoSize(1920, 1080)
        setInputSurface(recorderSurface)
        prepare()
        release()
    }
    
    this.recorderSurface = recorderSurface

}


private val stateCallback =
    object : CameraDevice.StateCallback() {
        override fun onOpened(cameraDevice: CameraDevice) {
            [email protected] = cameraDevice
            createRecordRequest()
            createCameraPreviewSession()
        }
    }



private fun openCamera() {
    //check permissions

    //pass in your camera id
        val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
        cameraManager.openCamera(cameraId, stateCallback, backgroundHandler)
}


private fun createCameraPreviewSession() {
    val surfaceList = mutableListOf<Surface>()
    previewReader?.surface?.let { surface -> surfaceList.add(surface) }
    captureReader?.surface?.let { surface -> surfaceList.add(surface) }

    //if i remove this line, the error doesnt happen, means something is wrong with the recorder surface
    recorderSurface?.let { surface -> surfaceList.add(surface) }

    val previewRequestBuilder =
        cameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)

    previewRequestBuilder.apply {
        addTarget(previewReader!!.surface)
        set(
            CaptureRequest.CONTROL_AE_MODE,
           CameraMetadata.CONTROL_AE_MODE_ON
            )
    }
    
    cameraDevice?.createCaptureSession(
        surfaceList,
        object : CameraCaptureSession.StateCallback() {
            override fun onConfigured(captureSession: CameraCaptureSession) {
                //perform configuration steps after, but it fails
            }

            override fun onConfigureFailed(cameraCaptureSession: CameraCaptureSession) {]
                //configuration will fail
                Timber.d("Configuration Failed")
            }
        },
        cameraHandler)
}

I am only encountering this issue on a Redmi Note 11 Pro 5G, I am not sure why but the Camera support level is LEVEL_3 if it matters.

I get the error below and camera shows me a black preview

Stream configuration failed due to: endConfigure:667: Camera 0: Unsupported set of inputs/outputs provided
2025-02-03 12:14:49.525  6817-7967  CameraCaptureSession      E  Session 0: Failed to create capture session; configuration failed

Stack trace:

025-02-03 12:14:49.000  6817-7688  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.000  6817-7688  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.003  6817-7688  libc                      W  Access denied finding property "persist.vendor.camera.privapp.list"
2025-02-03 12:14:49.004  6817-7688  CameraExtImplXiaoMi       D  initCameraDevice: 0
2025-02-03 12:14:49.020  6817-7688  CameraManager             I  Open camera top activityName is <activity name>
2025-02-03 12:14:49.040  6817-7402  CameraManagerGlobal       E  Camera 4 is not available. Ignore physical camera status change
2025-02-03 12:14:49.172  6817-7402  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.172  6817-7402  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.172  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.173  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.173  6817-7402  CameraManagerGlobal       W  ignore the torch status update of camera: 2
2025-02-03 12:14:49.173  6817-7402  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.173  6817-7402  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.173  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.173  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.174  6817-7402  CameraManagerGlobal       W  ignore the torch status update of camera: 3
2025-02-03 12:14:49.174  6817-7402  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.174  6817-7402  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.174  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.174  6817-7402  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.174  6817-7402  CameraManagerGlobal       W  ignore the torch status update of camera: 4
2025-02-03 12:14:49.175  6817-6835  CameraInjector            D  updateCloudCameraControllerInfoAsync: has aleardy start update task.
2025-02-03 12:14:49.175  6817-6835  CameraInjector            D  waitForResult: 
2025-02-03 12:14:49.175  6817-6835  libc                      W  Access denied finding property "vendor.camera.aux.packagelist"
2025-02-03 12:14:49.175  6817-6835  libc                      W  Access denied finding property "vendor.camera.aux.packagelistext"
2025-02-03 12:14:49.176  6817-6835  CameraManagerGlobal       W  ignore the torch status update of camera: 5
2025-02-03 12:14:49.314  6817-7688  BpBinder                  W  PerfMonitor binderTransact :  time=294ms interface=android.hardware.ICameraService code=4
2025-02-03 12:14:49.320  6817-7967  Camera2Controller         D  FPS range is [12, 30]
2025-02-03 12:14:49.409  6817-7967  CameraDevice-JV-0         D  waitUntilIdle: E. id = 0
2025-02-03 12:14:49.410  6817-7967  CameraDevice-JV-0         D  waitUntilIdle: X
2025-02-03 12:14:49.525  6817-7967  CameraDevice-JV-0         W  Stream configuration failed due to: endConfigure:667: Camera 0: Unsupported set of inputs/outputs provided
2025-02-03 12:14:49.525  6817-7967  CameraCaptureSession      E  Session 0: Failed to create capture session; configuration failed
2025-02-03 12:14:49.526  6817-7967  Camera2Con...iewSession   D  Configuration Failed

Relevant code, you may need to setup a few other things if you want to run it. The error goes away if I remove the recorderSurface from the list of surfaces when creating the capture session, but I cannot record then. It only happens for this specific phone so far.

private var recorderSurface: Surface? = null
private var previewReader: ImageReader? = null
private var captureReader: ImageReader? = null
private var cameraThread: HandlerThread? = null
private var cameraHandler: Handler? = null
private var mediaRecorder: MediaRecorder? = null

previewReader = ImageReader.newInstance(1920, 1080, ImageFormat.YUV_420_888, 5)
captureReader = ImageReader.newInstance(1920, 1080, ImageFormat.YUV_420_888, 5)
 
cameraThread = HandlerThread("Camera").also { it.start() }
cameraHandler = Handler(cameraThread.looper)

private fun createRecordRequest() {

    val recorderSurface = MediaCodec.createPersistentInputSurface()
    mediaRecorder = MediaRecorder().apply {
        setVideoSource(MediaRecorder.VideoSource.SURFACE)
        setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
        setOutputFile(context.cacheDir.path + "/file.mp4")
        setVideoEncoder(MediaRecorder.VideoEncoder.HEVC)
        setVideoEncodingBitRate(2_000_000)
        setVideoFrameRate(30)
        setVideoSize(1920, 1080)
        setInputSurface(recorderSurface)
        prepare()
        release()
    }
    
    this.recorderSurface = recorderSurface

}


private val stateCallback =
    object : CameraDevice.StateCallback() {
        override fun onOpened(cameraDevice: CameraDevice) {
            [email protected] = cameraDevice
            createRecordRequest()
            createCameraPreviewSession()
        }
    }



private fun openCamera() {
    //check permissions

    //pass in your camera id
        val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
        cameraManager.openCamera(cameraId, stateCallback, backgroundHandler)
}


private fun createCameraPreviewSession() {
    val surfaceList = mutableListOf<Surface>()
    previewReader?.surface?.let { surface -> surfaceList.add(surface) }
    captureReader?.surface?.let { surface -> surfaceList.add(surface) }

    //if i remove this line, the error doesnt happen, means something is wrong with the recorder surface
    recorderSurface?.let { surface -> surfaceList.add(surface) }

    val previewRequestBuilder =
        cameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)

    previewRequestBuilder.apply {
        addTarget(previewReader!!.surface)
        set(
            CaptureRequest.CONTROL_AE_MODE,
           CameraMetadata.CONTROL_AE_MODE_ON
            )
    }
    
    cameraDevice?.createCaptureSession(
        surfaceList,
        object : CameraCaptureSession.StateCallback() {
            override fun onConfigured(captureSession: CameraCaptureSession) {
                //perform configuration steps after, but it fails
            }

            override fun onConfigureFailed(cameraCaptureSession: CameraCaptureSession) {]
                //configuration will fail
                Timber.d("Configuration Failed")
            }
        },
        cameraHandler)
}
Share Improve this question asked Feb 3 at 5:55 ZysoraZysora 872 silver badges7 bronze badges 11
  • Why do you release the media recorder immediately after preparing it? – dev.bmax Commented Feb 3 at 8:56
  • @dev.bmax From what I recall its to allocate a buffer before passing the surface as an output target, commenting it out doesnt change anything though – Zysora Commented Feb 3 at 9:34
  • You can't use the recorder after it's released. – dev.bmax Commented Feb 3 at 9:36
  • @dev.bmax , I see, I have removed the release() line, I still get the configuration error though – Zysora Commented Feb 3 at 9:37
  • Did you try to use mediaRecorder.getSurface() instead of MediaCodec.createPersistentInputSurface()? – dev.bmax Commented Feb 3 at 9:39
 |  Show 6 more comments

1 Answer 1

Reset to default 0

Solved my problem. It seems for this phone, it cannot support both recording and image capture surfaces at the same time, it works if I remove either captureReader?.surface?.let { surface -> surfaceList.add(surface) } or recorderSurface?.let { surface -> surfaceList.add(surface) }

本文标签: