0

I want to save the frame in the Arraylist code works but the problem is frames are skipping while capturing the video. CameraArrray is the arraylist and ModelFrameProcess is the model class which takes bytes array and save into the arraylist. I have fixed the framerate as 15.

@Override
        public void onPreviewFrame(byte[] data, Camera camera) {

                 CameraArray.add(new ModelFrameProcess(data));
}

Sometimes frame rates are dropping up to 6 and sometimes it will take more than 20 frames. Any help ??

Ahmad Arslan
  • 4,498
  • 8
  • 38
  • 59

1 Answers1

1

To achieve best frame rate, you should avoid garbage collection. No allocations (new) should be made during acquisition.

You can use Camera.setPreviewCallbackWithBuffer(), but this bequires copy of the frame data aside, you should not add to the ArrayList the data bytearray received in the callback.

Often, the callbacks happen on the main (UI) thread. This may account to unstable frame rate. To push the callbacks off the UI thread you should use an eventLoop.

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • I have used main UI thread but the frame rate drops. I have started this work from the scratch but not i am recording the video by mediarecorder after that I am talking all the frames of the video and that works but when i create video from these frames it works but very very slow :( any help ? – Ahmad Arslan Jun 18 '14 at 12:55
  • Offline processing of encoded frames is CPU bound. You can try hardware decoder and encoder, but this will be slower than real-time manipulation. But on the other hand, offline processing is less time-critical, if you do it in background. – Alex Cohn Jun 18 '14 at 16:04