无法设置视频质量为媒体recorder.video产生闪烁视频 [英] Can't set video quality for media recorder.video produces flickering video

查看:377
本文介绍了无法设置视频质量为媒体recorder.video产生闪烁视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mMediaRecorder = new MediaRecorder();
    // Step 1: Unlock and set camera to MediaRecorder
    mCamera.unlock();
    mMediaRecorder.setCamera(mCamera);
    // Step 2: Set sources
    // activate this for recording with sound\

    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

    mMediaRecorder.setVideoSize(getMaxSupportedVideoSize().width,getMaxSupportedVideoSize().height);

    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    // Step 4: Set output file
    mMediaRecorder.setOutputFile(getOutputMediaFile("movie"));

    // Step 4: Set output file
    mMediaRecorder.setOutputFile(getOutputMediaFile("movie"));


    // Step 5: Set the preview output
    mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());

    mMediaRecorder.setOrientationHint(90);

以上code工作正常但是,视频的质量并不像一样的视频我拍了原生的Andr​​oid摄像头,我的视频使用的媒体记录器质量差比较到本机录制的,我怎么能提高视频的质量。

above code is working fine But, the quality of video is not as same as video i shoot over native android camera, my video recorded using media recorder is poor quality compare to the native one, how can i improve the video quality.

如果任何人知道帮我out.Thanks

If any one knows help me out.Thanks

推荐答案

我不是一个Java / Android开发,我使用Xamarin和C#,但我有很多同样的问题,我的解决办法应该是直接适用(甚至句法几乎是相同的)。

I'm not a Java/Android dev, I'm using Xamarin and C#, but I had much the same problem, and my solution should be directly applicable (even the syntax is almost identical).

我发现,如果你使用 setCamera (并且是previewing你开始你的mediaRecorder前的摄像头看到的),那么它不会让你改变对 mediaRecorder 质量设置。

I found that if you're using setCamera (and are previewing what the camera sees before you start up your mediaRecorder) then it won't let you change the quality settings on the mediaRecorder.

然后当你调用 mediaRecorder.start(),它要么崩溃或冻结或显示垃圾。

And then when you call mediaRecorder.start(), it either crashes or freezes or displays garbage.

基本上,只要摄像机是previewing,所述MediaRecorder将不会被允许启动在一个不同的质量到该相机已经录制。您需要

Basically, as long as the Camera is previewing, the MediaRecorder won't be allowed to start recording at a different quality to that which the camera already has. You need to


  1. 停止在相机 preVIEW,

  2. 拿走了preVIEW表面

  3. 分配摄像机到MediaRecorder(与 setCamera

  4. 将MediaRecorder了你所需要的品质

  5. 然后重新安装preVIEW表面

  1. stop the camera preview,
  2. take away its preview surface
  3. assign the camera to the MediaRecorder (with setCamera)
  4. set the MediaRecorder up with the quality you need
  5. then reattach the preview surface

然后,当你开始录制,一切正常,因为它应该。

Then when you start recording, everything works as it should.

所以你的情况,你打电话之前 mediaRecorder.setCamera(),请尝试以下操作:

So in your case, just before you call mediaRecorder.setCamera(), try the following:


mCamera.stop preVIEW();
mCamera.set previewDisplay(NULL);

然后再往下,做你的

mRecorder.setCamera()

这是我的解决方案。我现在可以设置视频质量为720p(或1080p),它完美的作品。

That was the solution for me. I can now set the video quality to 720p (or 1080p) and it works perfectly.

然而,当你停止录制,您的previewing也将停止。

However, when you stop recording, your previewing will also stop.

您可能会需要恢复您的

mCamera.set previewDisplay(M preview.getHolder()。getSurface())

要它是什么之前,并重新启动实际preVIEW。

to what it was before, and restart the actual preview.

我希望它为你工作太:)

I hope it works for you too :)

这篇关于无法设置视频质量为媒体recorder.video产生闪烁视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆