首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MediaRecorder.setVideoSize()在MediaRecorder.start()处导致RuntimeException (启动失败)

MediaRecorder.setVideoSize()在MediaRecorder.start()处导致RuntimeException (启动失败)
EN

Stack Overflow用户
提问于 2014-05-23 18:43:57
回答 2查看 1K关注 0票数 1

当我试图为我的MediaRecorder设置视频大小时,我会在start方法中得到一个RuntimeException。

代码语言:javascript
复制
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
if (isVideo)
    mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
if (isVideo) {
    mRecorder.setVideoSize(480, 360); // Works fine when this is removed
    mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
}

mRecorder.setOutputFile(newFilePath);

if (isVideo)
    mRecorder.setPreviewDisplay(surfaceHolder.getSurface());

mRecorder.prepare();    // Prepare recorder
mRecorder.start();      // Start recording
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-23 19:41:40

下面是我发现的最优雅的解决方案:

代码语言:javascript
复制
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
代码语言:javascript
复制
mRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
票数 3
EN

Stack Overflow用户

发布于 2014-05-23 19:09:19

使用Camera.Parameters获取支持的视频大小。相机经常不能任意缩放图像,大概是因为性能原因。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23836393

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档