blganesh
blganesh

Reputation: 3

Android Capture Surface Flinger

Many devices do not store the final display data in framebuffer, hence screen capture methods will not work on those devices.

I want to know how can get the final composition data from Surface Flinger?

If we can achieve the capture from surface flinger, it can help us to retrieve the video and camera preview despite there being no framebuffer.

Upvotes: 0

Views: 1780

Answers (1)

fadden
fadden

Reputation: 52313

You don't want or need the final composited video data. To record the camera preview, you can just feed it into a MediaCodec (requires Android 4.1, API 16). In Android 4.3 (API 18) this got significantly easier with some tweaks to MediaCodec and the introduction of the MediaMuxer class. See this page for examples, especially CameraToMpegTest.

It is possible to capture the composited screen; for example, the system UI does it to grab screenshots for the recent apps menu, and DDMS/ADT can capture screen shots for debugging. You need the appropriate permission to do this, though, and normal apps don't have it. It's restricted to make certain phishing schemes harder.

In no event are you able to capture DRM-protected video. Not even SurfaceFlinger gets to see that.

From the shell, you can use the screencap command (see source code).

Upvotes: 1

Related Questions