如何使用Camera API实现SlowMotion和TimeLapse视频录制 [英] How to implement SlowMotion and TimeLapse video recording using Camera API

查看:361
本文介绍了如何使用Camera API实现SlowMotion和TimeLapse视频录制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以使用Camera API来实现慢动作和延时录像?

Is there any way to implement Slow Motion and Time Lapse recording using Camera API?

我尝试使用MediaRecorder设置VideoFrameRateVideoBitRate VideoCaptureRate,但是对我没有任何作用.

I tried using MediaRecorder setting VideoFrameRate, VideoBitRate VideoCaptureRate but nothing work for me.

我已经成功地使用JNI进行了实现,但是我发现它花费了太多时间,并且还没有进行优化.

I have successfully implemented using JNI but i found it is taking too much time and not optimized as well.

如果找到其他可用的解决方案,请帮助我.

If you find any other solution available please help me.

推荐答案

我自己解决了这个问题,并且正在共享我的工作代码段,仅使用Camera API慢动作和延时拍摄即可实现

I solved it myself and i am sharing my working code piece , just using Camera API slow motion and timelapse are implemented

开始之前,您必须了解setCaptureRate(double fps)的定义

Before start you must know definition of setCaptureRate(double fps)

设置视频帧捕获率. 这可用于设置与视频帧捕获速率不同的视频帧捕获速率. 录制视频的播放速率.此方法还设置了记录 模式的时间流逝.在延时录像中,只有视频是 记录下来.经过一段时间后,与音频相关的参数将被忽略 如果应用程序设置了录制会话,则会开始录制会话.

Set video frame capture rate. This can be used to set a different video frame capture rate than the recorded video's playback rate. This method also sets the recording mode to time lapse. In time lapse video recording, only video is recorded. Audio related parameters are ignored when a time lapse recording session starts, if an application sets them.

TimeLapse
对于延时拍摄,您需要使用以下摄像机配置文件,根据您的视频帧的宽度和高度. 从个人资料下面选择任何一个,或者您可以根据需要选择其他人.

TimeLapse
For time lapse you need to use following camera profile , According to you video frame width and height. Choose any one from below profile or you may choose other according to your need.

profile = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_1080P);

profile = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_720P);

profile = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_480P);

现在您需要配置视频setCaptureRatesetVideoEncodingBitRate

And now you need configure your video setCaptureRate and setVideoEncodingBitRate

video_recorder.setCaptureRate(profile.videoFrameRate/6.0f);
video_recorder.setVideoEncodingBitRate(profile.videoBitRate);

最后,您需要将已配置的配置文件设置为MediaRecorder.

and at last you need to set your configured Profile to your MediaRecorder.

video_recorder.setProfile(profile);

慢动作
对于慢动作,您还需要配置 CamcorderProfile ,我正在对配置文件使用以下配置.

Slow Motion
For slow motion you also need to configure CamcorderProfile i am using following config for profile.

profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH_SPEED_HIGH);
 video_recorder.setCaptureRate(profile.videoFrameRate / 0.25f);
video_recorder.setVideoEncodingBitRate(profile.videoBitRate);
video_recorder.setProfile(profile);

对于慢动作,您必须使用CameraAPI2,否则它将无法正常工作.

For slowmotion you have to use CameraAPI2 otherwise it will not work.

这篇关于如何使用Camera API实现SlowMotion和TimeLapse视频录制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆