android MediaRecorder setVideoSize() 的问题
android MediaRecorder
可以捕获分辨率高于 320*240
的视频吗?
当我使用MediaRecorder::setVideoSize()
设置视频大小时,捕获的视频分辨率均为320*240
。更糟糕的是,较高的无法获得清晰的视频,它们莫名其妙地呈绿色。 (使用的编码器是h263
,格式是mpeg4
)
这里使用的Android版本是1.6
请问有人可以帮助我吗?
Can android MediaRecorder
capture video with resolution higher than 320*240
?
When I used MediaRecorder::setVideoSize()
to set the video size, the captured video were all at the resolution of 320*240
. Whats even worse, the higher ones can not get a clear video, they were somehow greenish. (encoder used is h263
, format is mpeg4
)
Android version used here is 1.6
Could you please anyone help me out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了与此处描述的类似的问题。我发现在调整视频大小之前我必须稍微重组我的代码。
重要的是 setVideoSize() 在 setVideoEncoder() 之前调用。我在文档中找不到这个,但是它解决了我设置特定视频分辨率的问题。
另请记住,应在 setVideoSize() 之前调用 setOutputFormat()。
正如旁注,setVideoFrameRate() 也是如此。如果在 setVideoEncoder() 之前没有调用它不会有任何影响。
这是使用 Android 2.3.3 进行测试的,
下面是一个代码示例:
I had an issue similar to what is described here. I turned out that I had to restructure my code slightly before I could adjust the video size.
The important thing is that setVideoSize() is called before setVideoEncoder(). I can't find this in the documentation, however it solved my problems with setting a specific video resolution.
Also keep in mind that setOutputFormat() should be called before setVideoSize().
As as side note the same is true for setVideoFrameRate(). If it is not called before setVideoEncoder() it will not have any affect.
This was tested with Android 2.3.3
Here is a code example:
首先,您需要确定您的相机支持什么。尝试:
这将告诉您相机支持的所有参数。其次,确保正确初始化 MediaRecorder,请参阅 google 文档以了解需要设置 MediaRecorder 的顺序。另外,如果您的 Camera.setPreviewSize 和 MediaRecorder.setVideoSize 不同,则可能会导致奇怪的行为。
First you are going to want to determine what your Camera supports. Try:
This will tell you all of the Camera's supported parameters. Second Make sure that you initialize your MediaRecorder properly see the google documentation for the order in which you need to set the MediaRecorder. Also, if your Camera.setPreviewSize and MediaRecorder.setVideoSize are different it can cause odd behavior.