Closed avinashyerrala closed 6 years ago
Sure, we can do that, and you're not going to get any memory exceptions. What is the issue?
I am wondering if there is any api that I can use to compress byte array in onPreviewFramecall back. Right now I am compressing the Image using the below code.
ByteArrayOutputStream jpegByteArrayOutputStream = new ByteArrayOutputStream(); new YuvImage(bytes, 17, 1280, 720, null).compressToJpeg(new Rect(0, 0, 1280, 720), 10, jpegByteArrayOutputStream);
Bitmap original = BitmapFactory.decodeByteArray(jpegByteArrayOutputStream.toByteArray(), 0, jpegByteArrayOutputStream.size());
Bitmap resized = Bitmap.createScaledBitmap(original, 360, 240, true);
((ByteBuffer) yuvImage.image[0].position(0)).put(getNV21(imageWidth, imageHeight, resized));
As you can see the compression is taking time and I am wondering if there is any Api in the sdk which can compress the byte array from onPreviewFrame call back
So the issue is that it takes too much time to compress? Then you'll need to use hardware accelerators. We can usually access those through the Android API, as used in this sample, for example: https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/ContinuousCaptureActivity.java https://github.com/google/grafika/blob/master/app/src/main/java/com/android/grafika/CircularEncoder.java
Hi, in onPreviewFrame call back the byte array I am receiving is huge because camera params is set to 1280 x 720. I cannot not change the camera parameters because my app is supposed to record a high def video in the background. Now the issue I am facing is I have to compress or scale byte array from onPreviewframe call back so that I can save it in byte buffer without any memory exceptions.
((ByteBuffer) yuvImage.image[0].position(0)).put(bytes)
If there is any possible to achieve it please advice.
Thanks.