使用 MediaRecorder 在 HTC Rezound 摄像机上录制 1080p 视频
Rezound 上的内置相机应用程序能够以 1080p 录制视频,但我在通过 Android API 执行此操作时遇到困难。如果我使用 CamcorderProfile.QUALITY_HIGH 中的设置,一切都会很好,但这只能提供 720x480 的视频。当我尝试将分辨率提高到 1080p 时,我的应用程序在 MediaRecorder.start() 上冻结,并且任何尝试使用相机的应用程序都会停止工作,直到我重新启动手机。
这是我用来配置 MediaRecorder 的代码:
CamcorderProfile prof = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
if(false){
prof.videoFrameHeight=1080;
prof.videoFrameWidth=1920;
}
prof.videoFrameRate=24;
prof.audioCodec=MediaRecorder.AudioEncoder.AAC;
prof.audioSampleRate=44100;
prof.audioBitRate=96;
prof.audioChannels=2;
mMediaRecorder.setProfile(prof);
当我启用 if 块内的代码时,应用程序冻结。我尝试准确复制从本机相机应用程序录制 1080p 时获得的视频设置。
如果能找到 Rezound 上使用的本机相机应用程序的来源,那就太好了。我检查了 Android 2.3.4 版本中的本机相机应用程序,它看起来不能支持任何高于 CamcorderProfile.QUALITY_HIGH 中指定的分辨率。
The built-in camera app on the Rezound is able to record video at 1080p, but I'm having trouble doing this from the Android API. Everything works great if I use the settings in CamcorderProfile.QUALITY_HIGH, but that only gives me video at 720x480. When I try to increase the resolution to 1080p, my app freezes on MediaRecorder.start() and any app that tries to use the camera stops working until I restart my phone.
Here's the code I'm using to configure MediaRecorder:
CamcorderProfile prof = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
if(false){
prof.videoFrameHeight=1080;
prof.videoFrameWidth=1920;
}
prof.videoFrameRate=24;
prof.audioCodec=MediaRecorder.AudioEncoder.AAC;
prof.audioSampleRate=44100;
prof.audioBitRate=96;
prof.audioChannels=2;
mMediaRecorder.setProfile(prof);
The app freezes when I enable the code inside the if block. I've tried to exactly copy the settings of the videos I get when I record 1080p from the native camera app.
It would be great to track down the source of the native camera app used on the Rezound. I checked out the native camera app in the 2.3.4 release of Android and it doesn't look like it can support any resolution higher than the one specified in CamcorderProfile.QUALITY_HIGH.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1920 * 1080 像素 * 3 种颜色(24fps)对于 Android 来说是一个非常大的数据。
即使使用硬件 H264 压缩,在具有精美采集卡的 PC 上实时执行此操作也很棘手
1920 * 1080 pixels * 3 colors at 24fps is an awful lot of data for a little Android.
Even with hardware H264 compression this is tricky to do in real time on a PC with a fancy capture card