录制视频时出现问题
我有一个在 Android 中录制视频的应用程序,在大多数手机和 API 级别上都没有问题。要记录的代码如下:
recorder.setCamera(cam);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
if(Integer.valueOf(android.os.Build.VERSION.SDK) > 7){
CamcorderProfile mProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(mProfile);
}else{
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
}
recorder.setOutputFile(path);
recorder.setPreviewDisplay(holder.getSurface());
recorder.prepare();
recorder.start();
由于未知原因,当此代码在运行 Android 2.3.5 的 Motorola MB632 中执行时,我在 Logcat 中收到以下错误:
OMXCodec : Buffer count/size less than minimum required
OMXCodec : Allocate Buffer failed - error = -2147483648
Media Recorder: start failed: -12
Camera : Error 100
Application : frameworks/base/media/libstagefright/MPEG4Writer.cpp:2966 mCodecSpecificData
并返回异常。我尝试了各种组合,但缓冲区大小似乎无法通过 API 函数进行更改。
I have an application that records video in Android without issues in most of the phones and API levels. The code to record is the following:
recorder.setCamera(cam);
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
if(Integer.valueOf(android.os.Build.VERSION.SDK) > 7){
CamcorderProfile mProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(mProfile);
}else{
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
}
recorder.setOutputFile(path);
recorder.setPreviewDisplay(holder.getSurface());
recorder.prepare();
recorder.start();
For an unknown reason when this code executes in a Motorola Model MB632 running Android 2.3.5 I get the following errors in the Logcat:
OMXCodec : Buffer count/size less than minimum required
OMXCodec : Allocate Buffer failed - error = -2147483648
Media Recorder: start failed: -12
Camera : Error 100
Application : frameworks/base/media/libstagefright/MPEG4Writer.cpp:2966 mCodecSpecificData
And returns an exception. I have tried all kind of combinations and the buffer size does not seem to be something that you can change from the API functions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到这是一个老问题,但我在运行 2.3.5 的 HTC Evo (PC36100) 上遇到了非常类似的问题。我注意到 SpyCamera (https://bitbucket.org/jimmod/spy-camera-os)在该设备上确实有效。查看代码后,我注意到我没有设置预览大小、预览格式和对焦模式,而 SpyCamera 则设置了。我添加了代码来设置这些值,当我开始录制时,我不再收到错误 100。
I realize this is an old question but I ran into a very similar problem on an HTC Evo (PC36100) running 2.3.5. I noticed that SpyCamera (https://bitbucket.org/jimmod/spy-camera-os) did work on this device. After reviewing the code I noticed that I was not setting the preview size, preview format, and focus mode while SpyCamera was. I added code to set these values and it I stopped getting the Error 100 when I started recording.