How to programmatically record high speed videos (60-120fps) on android

南楼画角 提交于 2019-12-06 14:39:23

问题


I have a piece of code that can use the android camera to record videos at QUALITY_HIGH using MediaRecorder and the camera api 1.

The camera code is based off: https://github.com/Glamdring/EasyCamera

And the video recording might resemble this: How to record video of particular width and height on samsung device android?

I can see from the documentation http://developer.android.com/intl/es/reference/android/media/CamcorderProfile.html#QUALITY_HIGH_SPEED_HIGH that there's a profile for high speed video but... calling this:

 CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH_SPEED_LOW);

throws an exception saying:

"E/MediaProfiles: The given camcorder profile camera 0 quality 2000 is not found"

calling:

 mMediaRecorder.setVideoFrameRate(100);

runs but the output video is not 100fps.

and calling:

 mMediaRecorder.setVideoFrameRate(CamcorderProfile.QUALITY_HIGH_SPEED_LOW);

throws an exception:

MediaRecorder: setVideoFrameRate failed: -22

I can use the built in camera application to record a "slow motion video" which will produce an mp4 at 120fps so I am pretty sure that the device can record a high speed video but something seems missing.


回答1:


First check the supported fps range of your camera device using getSupportedPreviewFpsRange.

I also did a test on a smartphone built-in camera app that supports slow motion and can indeed record at high frame rate (120fps). But from the results of getSupportedPreviewFpsRange, the frame rate is no more than 30fps.

I think the vendor does not originally provide the interface to record at high frame rate although the built-in camera app shows its hardware ability to do so. I guess this is because it may cause unexpected results such as hardware damage if it is not used properly.

The hardware requirement of recording high speed videos is higher than that of recording conventional videos. The built-in camera app may use a different recording strategy for slow motion videos. For example, it may use a lower resolution and different responses to light. Thus the access to programmatically recording high speed videos is not exposed.

However, there is a hack solution in here which utilizes the new camera2 API. You need root and it may not be stable.



来源:https://stackoverflow.com/questions/34881847/how-to-programmatically-record-high-speed-videos-60-120fps-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!