录制视频时出现问题

发布于 2024-12-18 04:17:50 字数 1157 浏览 2 评论 0原文

我有一个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的憧憬 2024-12-25 04:17:50

我意识到这是一个老问题,但我在运行 2.3.5 的 HTC Evo (PC36100) 上遇到了非常类似的问题。我注意到 SpyCamera (https://bitbucket.org/jimmod/spy-camera-os)在该设备上确实有效。查看代码后,我注意到我没有设置预览大小、预览格式和对焦模式,而 SpyCamera 则设置了。我添加了代码来设置这些值,当我开始录制时,我不再收到错误 100。

Camera.Parameters params = camera.getParameters();          

params.setPreviewSize(640, 480);
params.setPreviewFormat(ImageFormat.NV21);
if (params.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
    params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
camera.setParameters(params);

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.

Camera.Parameters params = camera.getParameters();          

params.setPreviewSize(640, 480);
params.setPreviewFormat(ImageFormat.NV21);
if (params.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
    params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
}
camera.setParameters(params);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文