googlearchive/android-Camera2Video

Unsupported set of inputs/outputs provided

Closed this issue · 11 comments

Hi i am getting the above error when using part of the example of recording video.

Here is the code below:

`  private fun setMediaOutputSurface(): Surface {

        var file = File(context.getExternalFilesDir(null).absolutePath)
        if(file.canWrite() && file.canRead()){
            Log.d("JJJ", "File location is fine")
        }

        mediaRecorder = MediaRecorder()
        mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE)

        mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
        mediaRecorder.setOutputFile(context.filesDir.absolutePath + "/"+System.currentTimeMillis() + ".mp4")
        mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264)

        mediaRecorder.setVideoSize(1280,720)


//        mediaRecorder.setVideoEncodingBitRate(17000000)
//        mediaRecorder.setVideoEncodingBitRate(512 * 1000)
        Log.d("JJJ", "FILE PATH = " + context.getExternalFilesDir(null).absolutePath + "/"+System.currentTimeMillis() + ".mp4")

        mediaRecorder.setVideoFrameRate(30)

        mediaRecorder.prepare()
        Log.d("JJJ", "Finished preparing")
//        mediaRecorder.start()
        return mediaRecorder.surface
    }`
` Log.d("JJJ", "onOpened and will now create handler and capture session")
                //create handler thread
                val thread = HandlerThread("MyHandlerThread")
                thread.start()
                val handler = Handler(thread.looper)

                startPreview(camera)

                //create capture session
                val mediaRecorderSurface = setMediaOutputSurface()
                val texture = mTextureView.surfaceTexture
                texture.setDefaultBufferSize(mTextureView.width, mTextureView.height)
                val surfaces = ArrayList<Surface>()
                val surfacePreview = Surface(texture)
                surfaces.add(surfacePreview)

                surfaces.add(mediaRecorderSurface)
                mPreviewBuilder = camera.createCaptureRequest(TEMPLATE_RECORD)
                mPreviewBuilder.addTarget(mediaRecorderSurface)
                Log.d("JJJ", "About to create capture session")
//                camera.createCaptureSession(surfaces, cameraCaptureSessionCallBack,handler)
                camera.createCaptureSession(Collections.singletonList(mediaRecorderSurface),cameraCaptureSessionCallBack, handler)
                Log.d("JJJ", "Created thread handler and capture session")
            }`

error happens when i execute camera.createCaptureSession

I even tried your whole code and just ran it in my Pi 3 device using android things and it diddnt work

Have you solved the problem?
I have met a problem just like you.
"Unsupported set of inputs/outputs provided"
If you solved the problem, please contact me. Thank you very much!

If there is only one surface, createCaptureSession works well.
But if there are two surfaces, createCaptureSession function call will failed, and report "Unsupported set of inputs/outputs provided".
Following is android sdk source code describe:
"
// OK. camera service can reject stream config if it's not supported by HAL
// This is only the result of a programmer misusing the camera2 api.
"

According to the above information, do you know how to solv the problem?

I meet this problem ,but i don't know how to resolve it; please help

i alse meet this problem

Any solutions yet?

@jaggernaut007 what did? There is no ImageFormat used in my code above!

@jonneymendoza Maybe that is the problem. For me changing the image format and resolution the capture session gets, worked. My code is running fine now!

What is? Are you actually recording video like how i am? Could you please post your code that records and saves a video clip?

This sample has been migrated to a new location where we can accept Pull Requests (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!