与Android MediaRecorder setVideoSize问题()问题、Android、MediaRecorder、setVideoSize

2023-09-06 08:10:01 作者:心葬未亡人

能否Android版 MediaRecorder 拍摄视频分辨率高于 320 * 240

Can android MediaRecorder capture video with resolution higher than 320*240?

当我用 MediaRecorder :: setVideoSize()设置视频的大小,捕获的视频都在 320 * 240分辨率。什么更糟的是,较高的人不能得到清晰的视频,他们莫名其妙地绿。 (EN codeR采用的是 H263 ,格式为 MPEG4

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)

这里使用的Andr​​oid版本 1.6

Android version used here is 1.6

你能不能请人帮我吗?

推荐答案

我有类似这里所描述的问题。我原来,我不得不重新调整我的code稍微之前,我可以调整视频的大小。

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.

最重要的是,setVideoSize()被调用之前setVideoEn codeR()。我找不到这个文件中,但它解决了我的问题,设置特定的视频分辨率。 也请记住,setOutputFormat()应该setVideoSize()之前调用。

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().

由于作为边注的情况也是如此setVideoFrameRate()。如果之前setVideoEn codeR不叫(),它不会有任何影响。

As as side note the same is true for setVideoFrameRate(). If it is not called before setVideoEncoder() it will not have any affect.

这是采用Android 2.3.3测试

This was tested with Android 2.3.3

下面是一个code例如:

Here is a code example:

recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoSize(640,480);
recorder.setVideoFrameRate(30);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);