MediaRecorder 准备失败

发布于 2024-08-28 07:58:10 字数 624 浏览 8 评论 0原文

我是新来的。我一直在尝试使用 Android 模拟器创建一个视频捕获应用程序,但没有取得太大成功。据我所知,并浏览了互联网上的所有示例和代码(本网站和其他网站),我肯定还缺少一个步骤。

我尝试在 JonPro 制作的该线程末尾附近使用此示例: http://www.anddev.org/viewtopic.php?p=24723# 24723

,我尝试过自己制作,但媒体记录器总是会在准备阶段失败,并显示最无用的“准备失败”消息。我不知道我错过了什么。我似乎有正确的权限,并且根据模拟器安装了SDCard。我应该使用 2.1 以外的 Android SDK 版本吗?

尽管该论坛中的代码声称可以工作,但我发现缺少这一行: 记录器.setCamera(相机);

但仍然没有喜悦,日志显示: “获取相机(0x16b70)参数失败” 当调用prepare()但它仍然没有意义,因为预览可以,但没有录制!任何帮助或建议将不胜感激。

编辑:任何人都可以确认这适用于 SDK 和模拟器吗?或者我是在浪费时间试图让它在这个版本中工作。我能否获得准备功能的源代码,因为它是开源的?

I'm new here. I have been trying to create a video capture app using the android emulator without much success. As far as I know and looking through all the samples and code on the internet (this site and others), I must still be missing a step.

I've tried using this sample near the end of this thread made by JonPro:
http://www.anddev.org/viewtopic.php?p=24723#24723

and I've tried making my own but the media recorder would always fail on the prepare stage with the most unhelpful message of 'prepare failed'. I have no clue what I am missing. I seem to have the correct permissions and a SDCard is mounted according to the emulator. Should I be using a android SDK version other than 2.1?

Even though the code in that forum claims to work, I figured out that this line was missing:
recorder.setCamera(camera);

But still no joy as the logs shows that:
'Failed to get camera(0x16b70) parameters'
when prepare() is called but it still doesn't make sense as the preview is okay, but no recording! Any help or suggestions will be appreciated.

Edit: Can anyone confirm that this can work for the SDK and the emulator? or I'm I wasting my time trying to get this to work in this version. Am I able to get the source code for the prepare function as it is OpenSource?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

千柳 2024-09-04 07:58:10

解决此问题的方法是必须在准备之前设置 mCameraDevice.unlock()。重要的是,这是在 mCameraDevice.setPreviewDisplay(mHolder); 之后设置的。

示例:

/*--------------------------------------surfaceCreated---------------------------------------------*/
/**
 * Surface Created sets that the surface is created.
 */
 public void surfaceCreated(SurfaceHolder arg0) {
     // TODO Auto-generated method stu1595
        try {
            Log.d(LOG_TAG, "setPreviewDisplay enter");
            mCameraDevice.setPreviewDisplay(mHolder);
            Log.d(LOG_TAG, "setPreviewDisplay exit");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        mCameraDevice.unlock();
        Log.d("*************", "***********unlock()****");
     isSurfaceCreated = true;


 }

BR
PN

The fix for this problem is mCameraDevice.unlock() must be set before prepare. It's important that this is set after mCameraDevice.setPreviewDisplay(mHolder);

example:

/*--------------------------------------surfaceCreated---------------------------------------------*/
/**
 * Surface Created sets that the surface is created.
 */
 public void surfaceCreated(SurfaceHolder arg0) {
     // TODO Auto-generated method stu1595
        try {
            Log.d(LOG_TAG, "setPreviewDisplay enter");
            mCameraDevice.setPreviewDisplay(mHolder);
            Log.d(LOG_TAG, "setPreviewDisplay exit");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        mCameraDevice.unlock();
        Log.d("*************", "***********unlock()****");
     isSurfaceCreated = true;


 }

BR
P.N

没企图 2024-09-04 07:58:10
recorder.setVideoSize(176, 144);
recorder.setVideoFrameRate(20);
recorder.setAudioChannels(1);
recorder.setPreviewDisplay( mHolder.getSurface());

这对我有帮助。调试期间查看 logcat

recorder.setVideoSize(176, 144);
recorder.setVideoFrameRate(20);
recorder.setAudioChannels(1);
recorder.setPreviewDisplay( mHolder.getSurface());

this helped for me. Look in logcat during debug

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文