android MediaRecorder setVideoSize() 的问题

发布于 2024-09-28 18:47:28 字数 311 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

用心笑 2024-10-05 18:47:28

我遇到了与此处描述的类似的问题。我发现在调整视频大小之前我必须稍微重组我的代码。

重要的是 setVideoSize() 在 setVideoEncoder() 之前调用。我在文档中找不到这个,但是它解决了我设置特定视频分辨率的问题。
另请记住,应在 setVideoSize() 之前调用 setOutputFormat()。

正如旁注,setVideoFrameRate() 也是如此。如果在 setVideoEncoder() 之前没有调用它不会有任何影响。

这是使用 Android 2.3.3 进行测试的,

下面是一个代码示例:

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);       

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:

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);       
面如桃花 2024-10-05 18:47:28

首先,您需要确定您的相机支持什么。尝试:

            List<String> anti = params.getSupportedAntibanding(); 
    List<String> color = params.getSupportedColorEffects();
    List<String> focus = params.getSupportedFocusModes(); 
    List<String> flash = params.getSupportedFlashModes();
    List<Size> previewSize = params.getSupportedPreviewSizes();
    List<Size> sizes = params.getSupportedPictureSizes();
    List<Integer> frameRates = params.getSupportedPreviewFrameRates();
    List<Integer> pictureFormats = params.getSupportedPictureFormats();
    List<String> scene = params.getSupportedSceneModes(); 
    List<String> white = params.getSupportedWhiteBalance();

这将告诉您相机支持的所有参数。其次,确保正确初始化 MediaRecorder,请参阅 google 文档以了解需要设置 MediaRecorder 的顺序。另外,如果您的 Camera.setPreviewSize 和 MediaRecorder.setVideoSize 不同,则可能会导致奇怪的行为。

First you are going to want to determine what your Camera supports. Try:

            List<String> anti = params.getSupportedAntibanding(); 
    List<String> color = params.getSupportedColorEffects();
    List<String> focus = params.getSupportedFocusModes(); 
    List<String> flash = params.getSupportedFlashModes();
    List<Size> previewSize = params.getSupportedPreviewSizes();
    List<Size> sizes = params.getSupportedPictureSizes();
    List<Integer> frameRates = params.getSupportedPreviewFrameRates();
    List<Integer> pictureFormats = params.getSupportedPictureFormats();
    List<String> scene = params.getSupportedSceneModes(); 
    List<String> white = params.getSupportedWhiteBalance();

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文