Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL filter prototype #5444

Open
rom1v opened this issue Nov 3, 2024 · 2 comments
Open

OpenGL filter prototype #5444

rom1v opened this issue Nov 3, 2024 · 2 comments

Comments

@rom1v
Copy link
Collaborator

rom1v commented Nov 3, 2024

On-device OpenGL video filters will allow to:

I wrote a quick&dirty prototype (branch opengl_filter), but I'm blocked because onNewFrameAvailable() is never called:

public void onFrameAvailable(SurfaceTexture surfaceTexture) {

I'm pretty sure this is related to threading (setOnFrameAvailableListener() also accepts a Handler), but I did not manage to make it work.

Once this listener is called on every frame, I can implement the shaders to perform the transforms I want, but I need this to work to get started.

Any help welcome.

@yume-chan
Copy link
Contributor

yume-chan commented Nov 3, 2024

https://github.com/Genymobile/scrcpy/compare/opengl_filter...yume-chan:scrcpy:opengl_filter_v2?expand=1

I copied some OpenGL code from https://github.com/google/grafika, and mimicked how https://cs.android.com/android/platform/superproject/main/+/main:frameworks/av/cmds/screenrecord/Overlay.cpp initialized it.

updateTexImage needs to be called on the same thread as the SurfaceTexture is created, and the SurfaceEncoder thread is busy in a while loop, so we can only create it in a new thread.

setOnFrameAvailableListener requires the current (or specified) looper is in looping state.

@rom1v
Copy link
Collaborator Author

rom1v commented Nov 3, 2024

Thank you very much! It works perfectly.

I have everything I need to start working on it 🎉 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants