setVideoSize()以高分辨率崩溃

Iam*_*414 6 video android video-capture video-processing android-camera

我想给用户一个设置不同分辨率的选项.

我试过这个解决方案

camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
....
....
mCamera.unlock();
recorder.setCamera(mCamera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(camcorderProfile);
Run Code Online (Sandbox Code Playgroud)

它完美地工作:质量好,一切......

当我把它设置为

camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
Run Code Online (Sandbox Code Playgroud)

随着FLASH,视频出现了绿色和其他一些奇怪的颜色.

我在线阅读,人们说这是因为我的手机可能不支持QUALITY_480P.好吧,它会让人感觉到.

因此,我开始研究不同的解决方案,所以我试过......

recorder.setVideoSize(640, 480);
Run Code Online (Sandbox Code Playgroud)

效果很好,

但视频看起来非常难看.

接下来,我检查了支持的视频列表.

List<Size> GetSupportedVideosResolutions =  params.getSupportedVideoSizes();
Run Code Online (Sandbox Code Playgroud)

分辨率:1280x720在列表中,所以

我试图设置以下内容:

recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoSize(1280,720);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); 
Run Code Online (Sandbox Code Playgroud)

它给了我一个RuntimeException错误.

问题是

为什么不能让我设置手机上可用的更高分辨率?

任何帮助将不胜感激,

谢谢.

编辑:添加了错误日志

04-18 17:40:07.391: E/AndroidRuntime(30191): java.lang.RuntimeException: start failed.
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.media.MediaRecorder.start(Native Method)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at test.com.VideoActivity.prepare_StartRecorder(VideoActivity.java:1009)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at test.com.VideoActivity.Recorder_Start_Stop(VideoActivity.java:1102)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at test.com.VideoActivity$6.onClick(VideoActivity.java:246)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.view.View.performClick(View.java:4489)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.widget.CompoundButton.performClick(CompoundButton.java:104)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.view.View$PerformClick.run(View.java:18803)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.os.Handler.handleCallback(Handler.java:730)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.os.Looper.loop(Looper.java:137)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at android.app.ActivityThread.main(ActivityThread.java:5493)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at java.lang.reflect.Method.invokeNative(Native Method)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at java.lang.reflect.Method.invoke(Method.java:525)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
04-18 17:40:07.391: E/AndroidRuntime(30191):    at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

Iam*_*414 3

我想出了问题所在。这可能对其他人有帮助。我最终得到:

camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
recorder.setVideoSize(1280, 720);   //NEEDED or it will crash
Run Code Online (Sandbox Code Playgroud)

代码:

camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
....
....
mCamera.unlock();
recorder.setCamera(mCamera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(camcorderProfile);
recorder.setVideoSize(1280 720);  //NEEDED or it will crash
....
...
Run Code Online (Sandbox Code Playgroud)

//或者

CamcorderProfile.get(CamcorderProfile.QUALITY_1080P);
recorder.setProfile(camcorderProfile);
recorder.setVideoSize(1920, 1080);  //NEEDED or it will crash
Run Code Online (Sandbox Code Playgroud)