mtsahakis / MediaProjectionDemo

One Activity sample app of using Android Lollipop MediaProjection API to capture device screenshots
Other
210 stars 76 forks source link

Increase number of screenshots per sec #6

Closed Raj123456788 closed 7 years ago

Raj123456788 commented 7 years ago

Hello There, I am kind of newbie and looking to improve number of frames captured per second. Currently, getting 9-10FPS. How can I improve to capture more screenshots. Sorry if it is dumb question.

mtsahakis commented 7 years ago

Hi,

I guess you could decrease the size of the image captured, I doubt you need a full res image.

Maybe something like this:

int scalingFactor = 3; mWidth = ((size.x / scalingFactor + 3) & ~3); mHeight = size.y / scalingFactor;

Let me know if it had any impact.

Raj123456788 commented 7 years ago

I need 1080p. I will give it a try.

Raj123456788 commented 7 years ago

If I set the capture resolution to mWidth = 1920; mHeight = 1080; How can I improve the frame rate? Calling Image reader in a timer? I am going to try it anyways. you think anything will get screwed up?

mtsahakis commented 7 years ago

Hi,

I am not sure a Timer would help, screen capture occurs in its own handling Thread after all.

At this point I would seek to find where delays occur.

Try to measure the frame rate when you are just grabbing an image from the framework without doing any additional work, i.e. without creating a ByteBuffer+Bitmap+saving Bitmap to file system. That should be the maximum frame rate you can get. Then see how you can improve on that.

In my case, as I did not need high res output, scaling down the image captured improved performance.

Raj123456788 commented 7 years ago

It Did not make any difference. Sorry for the late reply.