Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get screenshots from SurfaceComposerClient

Is it possible to use SurfaceComposerClient to get screenshots, the way MediaCodec does with createInputSurface().

I cant use MediaCodec for that because I need raw video and not encoded data.

since 4.3 it seems that ScreenshotClient cant do multiple screenshots.

like image 806
jacob Avatar asked Mar 09 '26 21:03

jacob


1 Answers

Yes, assuming you're running as shell or root, and you don't mind using non-public native APIs (i.e. you don't care if your app breaks every time a new version of the OS rolls out).

The canonical example is screenrecord, introduced in Android 4.4. It creates a virtual display and directs the output to a Surface. For normal operation a MediaCodec input surface receives the output. For the "bugreport" mode introduced in screenrecord v1.1, the output goes to a GLConsumer (roughly equivalent to a SurfaceTexture), which is rendered to a Surface with overlaid text.

like image 165
fadden Avatar answered Mar 12 '26 10:03

fadden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!