mtsahakis / MediaProjectionDemo

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

No JPEG header detected #1

Closed alessandroRoaro closed 9 years ago

alessandroRoaro commented 9 years ago

Thanks for sharing your code.

I tested the app on a Nexus 9 and on a Genymotion emulator (both with API 21) and I wasn't able to retrieve a valid image. I kept getting these logs:

ImageReader_imageSetup: Receiving JPEG in HAL_PIXEL_FORMAT_RGBA_8888 buffer. Image_getJpegSize: No JPEG header detected, defaulting to size=width=11993088

mtsahakis commented 9 years ago

These commends come from backing cpp ImageReader code telling us that the image format will be JPEG/RGBA_888. The aforementioned comments are normal. I made a slight update, its quicker to compress a bitmap an JPEG, you might want to get a pull and look into that. I haven't tested the code on a proper device though, only on an emulator, so let me know if you still have issues after the update.

robertoandrade commented 9 years ago

I see the same issue here on my 5.0.1 emulator and the images that it saves are all black. Tried it on a Nexus 5 running 5.0.1 and get the following errors (any idea?):

01-07 19:19:06.626: E/BufferQueueProducer(16027): [unnamed-16027-0] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count

The callback is never called.

mtsahakis commented 9 years ago

Did you manage to solve this? Do you manage to grab any images or the app hangs completely?

It looks like it can't allocate the native surface and there is not much information on the internet regarding this error.

On the emulator I would suggest taking hardware acceleration off.

alessandroRoaro commented 9 years ago

Yes now it's working, apparently changing the image format to PixelFormat.RGBA_8888 solved the problem

mtsahakis commented 9 years ago

I made the suggested change on the project, it also improves a bit frame capture rate on my test device (Nexus 7 with Android 5.0.2).