gpt4 book ai didi

android - setVideoSize() 在高分辨率下崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:10:01 29 4
gpt4 key购买 nike

我想为用户提供设置不同分辨率的选项。

我试过这个解决方案

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

它运行完美:质量好,一切...

当我把它设置为

camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);

打开FLASH,视频出现绿色和其他一些奇怪的颜色。

我在网上看到有人说这是因为我的手机可能不支持 QUALITY_480P。好的,这是有道理的。

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

recorder.setVideoSize(640, 480);

效果很好,

但是视频看起来很丑。

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

List<Size> GetSupportedVideosResolutions =  params.getSupportedVideoSizes();

分辨率: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);

它给了我一个 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)

最佳答案

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

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

代码:

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

//或

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

关于android - setVideoSize() 在高分辨率下崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29724097/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com