CameraX with Mediacodec

61 views
Skip to first unread message
Assigned to xi...@google.com by wuj...@google.com

jinlong zhu

unread,
Apr 4, 2023, 5:37:07 AM4/4/23
to Android CameraX Discussion Group
I get the Surface through the method createInputSurface() of MediaCodec, and then associate it with CameraX in the following way:

Preview encodePreview = new Preview.Builder()
.setTargetResolution(new Size(1280, 720))
.build();
encodePreview.setSurfaceProvider(new Preview.SurfaceProvider() {
@Override
public void onSurfaceRequested(@NonNull SurfaceRequest request) {
request.provideSurface(mInputSurface, ContextCompat.getMainExecutor(TestActivity.this), new Consumer<SurfaceRequest.Result>() {
@Override
public void accept(SurfaceRequest.Result result) {
// result.getSurface().release();
}
});
}
});

But an exception is thrown when running

Fatal Exception: java.lang.IllegalStateException: glDrawArrays: GL error 0x505
at androidx.camera.core.processing.OpenGlRenderer.checkGlErrorOrThrow(OpenGlRenderer.java:653)
at androidx.camera.core.processing.OpenGlRenderer.render(OpenGlRenderer.java:254)
at androidx.camera.core.processing.DefaultSurfaceProcessor.onFrameAvailable(DefaultSurfaceProcessor.java:175)
at android.graphics.SurfaceTexture$1.handleMessage(SurfaceTexture.java:212)
at android.os.Handler.dispatchMessage(Handler.java:117)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:293)
at android.os.HandlerThread.run(HandlerThread.java:67)

Xi Zhang

unread,
Apr 11, 2023, 4:31:44 PM4/11/23
to Android CameraX Discussion Group, zjl...@gmail.com
Thanks for reporting the issue. Which version of CameraX are you using? Does the error happen on a specific device? 

It's the OpenGL post-processing in preview caused the 0x505 error. Is there a reason that you want to record the preview stream instead of using the VideoCapture UseCase? 

Also it would be great if you could provide a minimal reproducible code sample.

Thanks
Reply all
Reply to author
Forward
0 new messages