Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

android - Why FPS is not same as original camera app

I tested with original camera application (video mode) comes with Samsung Galaxy Tab 8.9. The saved front camera video able to achieve 24 fps, 640x480. (By looking at the properties of video file after transfer to Windows machine)

However, while I write front Camera code to test.

mCamera2.setPreviewCallbackWithBuffer(new PreviewCallback() {
    public void onPreviewFrame(byte[] data, Camera camera) {
        // image processing code placed here.
    }
});

The maximum result I can achieve is (without saving video to disk. I merely measure the callback function onPreviewFrame triggered rate)

  • 15 fps
  • 320x240, 800x600

I would like to have performance same as Samsung original camera app. May I know am I missing certain technique?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The reason you're seeing these results is that your callback is getting a sampling of the video rather than the actual video.

When the camera is dumping it's output to the file system, it's doing a very low level write operation that copies the data from the camera's video buffer to the file system, without ever touching the JVM. This is required to keep the video at a high quality and low latency, and ensures a smooth final video. If you need to do video processing on the actual video, it is better done after the video is already done being recorded.

The preview callback is merely giving you a sample of the actual video capture, not the entire video capture -- since most 15fps videos will still look smooth, the preview callback is only giving you a lower resolution, lower fps preview version of the actual video being captured. Even the built-in samsung capture application will only show the preview version, because that's all the preview interface is being given.

It would be impossible to get an accurate benchmark of video recording in Android from anything other than the file system dump or the low-level byte array data structures (using a JNI wrapper for example). It would be easy enough, but attempting to do it directly would block input reading from the camera and blow your benchmarks anyway.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...