如何获取Android中支持的摄像机分辨率?
我正在编写一个应用程序,允许用户使用手机摄像头捕捉视频。我使用自己的代码来录制视频,而不是 Android 内置的相机应用程序。
一切工作正常,除了我需要能够访问支持的相机分辨率列表,以便我可以在运行时选择使用哪一个。我正在寻找类似 getSupportedPictureSizes()
的东西,但用于视频。 Android 3.0 有此功能,但我正在寻找 2.2 的功能。
截至目前,我正在使用 CamcorderProfile.QUALITY_HIGH / QUALITY_LOW
,但这只给了我两个选项,并且在我测试过的手机上,文件大小处于两个极端。(QUALITY_LOW 为 216 kb /s 且 QUALITY_HIGH > 3 MB/s)
任何帮助将不胜感激, 谢谢你!
I am writing an app where I am allowing the user to capture video using the phones camera. I am using my own code to record the video as opposed to Androids built in camera app.
Everything is working OK except I need to be able to access the list of supported camera resolutions so I can choose at runtime which one to use. I am looking for something like getSupportedPictureSizes()
but for video. Android 3.0 has this functionality but I am looking for something for 2.2.
As of right now I am using CamcorderProfile.QUALITY_HIGH / QUALITY_LOW
, but this only gives me two options and on the phones I have been testing on, the file sizes are at each extreme.(QUALITY_LOW is 216 kb/s and QUALITY_HIGH is > 3 MB/s)
Any help would be greatly appreciated,
Thank You!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试使用
getSupportedVideoSizes()
方法?Camera.Parameters
类中的此方法返回 Size 对象的列表。如果相机没有单独的预览和视频输出,它将返回
null
。 此处的答案表明,当返回null
时,您可以使用getSupportedPreviewSizes()
列表。Did you try to use the
getSupportedVideoSizes()
method fromCamera.Parameters
class?This method returns a list of Size objects. It will return
null
if the camera does not have separate preview and video output. The answer here indicates that when this returnsnull
you may use thegetSupportedPreviewSizes()
list.好吧,我想我明白了。它似乎在我测试过的手机上正常工作。
Ok I think I figured it out. It seems to work correctly on the phones I have been testing on.