MasayukiSuda / GPUVideo-android

This library apply video filter on generate an Mp4 and on ExoPlayer video and Video Recording with Camera2.
MIT License
658 stars 179 forks source link

Capturing black images on various devices #82

Closed heitaoflower closed 3 years ago

heitaoflower commented 3 years ago

I encountered this issue at SAMSUNG and Huawei series devices.

The essential cause of the problem is the time to invoke the queueevent function.

What we should do is that always invoking this function after the draw frame.

Here is my tinkered code snippet.

public final void onDrawFrame(final GL10 gl) {
        synchronized (runOnDraw) {
            while (!runOnDraw.isEmpty()) {
                runOnDraw.poll().run();
            }
        }

        framebufferObject.enable();

        onDrawFrame(framebufferObject);

        GLES20.glBindFramebuffer(GL_FRAMEBUFFER, 0);

        GLES20.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        normalShader.draw(framebufferObject.getTexName(), null);

        synchronized (runOnDrawEnd) {
            while (!runOnDrawEnd.isEmpty()) {
                runOnDrawEnd.poll().run();
            }
        }

    } 

Anyway, hope you guys fix this issue.