Android的捕捉视频mediaRecorder.start()失败-19 [英] Android Capture video mediaRecorder.start() failed -19

查看:365
本文介绍了Android的捕捉视频mediaRecorder.start()失败-19的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要记录的录像,并保存它,但我得到错误的启动()的媒体记录方法:失败 - 19 (什么就是这个错误应该是什么?有一个在文档上没有评论:() 我这个错误第二天的战斗,我已经尝试了多个codeS(谷歌的教程,英特尔的样品,...)我发现所有网站上,但不能使工作的任何人。请帮我看看是什么原因造成的问题。我甚至开始怀疑,我的手机(SE生活,wt19i)是能够记录视频(但默认的摄像头应用程序正常工作)的。说真的,,没有任何人有任何想法的我应该尝试/检查/修复

I need to record the video and save it but I get error on start() method of media recorder: failed - 19 (what is this error supposed to be? There is no comment on it in documentation :( ) I'm fighting with this error second day, I have tried multiple codes (google tutorial, intel sample, ...) I found all over the web, but couldn't make work any of them. Please help me find what is causing the problem. I'm even starting to doubt that my mobile phone (SE live, wt19i ) is capable of recording the video (but default camera app works fine). Really, please, does anybody have any idea what should I try/check/fix?

下面是我的code记录:

Here is my code for recording:

public boolean record()
        {
            // if already recording, return
            if( recording ) return false;

            // We are recording
            recording = true;
            // log start of the method
            System.out.println("CameraPreview::record() - Method start");

            // Have tried to stop preview before record - didnt help
            //mCamera.stopPreview();
            mCamera.unlock();

            mRecorder = new MediaRecorder();
            // have tried this listener to get some extra info (doesnt work)
            mRecorder.setOnErrorListener(new MediaRecorder.OnErrorListener() {              
                public void onError(MediaRecorder mr, int what, int extra) {
                    System.out.println("MediaRecorder::onError listener:"+what+" - "+extra);

                }
            });


            mRecorder.setCamera(mCamera);

            // Set media recorder properties
            mRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
            mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

            mRecorder.setProfile( CamcorderProfile.get( CamcorderProfile.QUALITY_LOW ) );
            // have tried to set format without profile - didnt help
            //mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            //mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            //mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);

            mRecorder.setOutputFile("/sdcard/MVR_video.3gp");
            mRecorder.setPreviewDisplay(mHolder.getSurface());

            // Prepare media recorder
            try {
                mRecorder.prepare();
            } catch (Exception e) {
                Log.d("MyVideoRecord", "Error preparing media recorder: " + e.getMessage());
                System.out.println("CameraPreview::record() - prepare() thrown an exception");

                stopRecord();
                return false;
            }

            // Have tried to wait until prepare is done - didnt help
            try {Thread.sleep(1000); } catch( Exception e){}
            try {
                mRecorder.start();
            } catch (Exception e) {
                Log.d("MyVideoRecord", "Error starting media recorder: " + e.getMessage());
                System.out.println("CameraPreview::record() - start() thrown an exception");
                System.out.println("Exception: "+e.getMessage());
                e.printStackTrace();

                stopRecord();
                return false;
            }

            System.out.println("CameraPreview::record() - Method returning TRUE");
            return true;
        }

我有一个摄像头,存储卡和音频清单文件权限请求。我已经将的minSdkVersion 以10和目标15

I have permission requests for camera, memory card and audio in manifest file. I have set minSdkVersion to 10 and target to 15

下面是 LogCat中

I/System.out(3990): CameraPreview::record() - Method start
I/MediaRecorderJNI(3990): prepare: surface=0x1f8e10 (identity=171)
E/MediaRecorder(3990): start failed: -19
D/MyVideoRecord(3990): Error starting media recorder: start failed.
I/System.out(3990): CameraPreview::record() - start() thrown an exception
I/System.out(3990): Exception: start failed.
W/System.err(3990): java.lang.RuntimeException: start failed.
W/System.err(3990):     at android.media.MediaRecorder.start(Native Method)
W/System.err(3990):     at com.example.myvideorecord.CameraPreview.record(CameraPreview.java:142)
W/System.err(3990):     at com.example.myvideorecord.MainActivity.onOptionsItemSelected(MainActivity.java:101)
W/System.err(3990):     at android.app.Activity.onMenuItemSelected(Activity.java:2502)
W/System.err(3990):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:969)
W/System.err(3990):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
W/System.err(3990):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
W/System.err(3990):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
W/System.err(3990):     at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:468)
W/System.err(3990):     at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:126)
W/System.err(3990):     at android.view.View$PerformClick.run(View.java:14263)
W/System.err(3990):     at android.os.Handler.handleCallback(Handler.java:605)
W/System.err(3990):     at android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err(3990):     at android.os.Looper.loop(Looper.java:137)
W/System.err(3990):     at android.app.ActivityThread.main(ActivityThread.java:4441)
W/System.err(3990):     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(3990):     at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err(3990):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
W/System.err(3990):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
W/System.err(3990):     at dalvik.system.NativeStart.main(Native Method)

编辑:

我加入我的清单文件:

I'm adding my manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myvideorecord"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:debuggable="true" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".CameraPreview"
            android:screenOrientation="landscape"
            ></activity>
    </application>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-feature android:name="android.hardware.camera" />
</manifest>

EDIT2

我曾尝试运行这个程序的我的表兄弟暴徒(其本身,而是另一种模式)和,它的工作没有任何问题。由于心不是Android的更新我的电话,我试着去修理它通过原来的索尼PC伴侣软件。我希望后,它会工作,我想这是不可能的降级Android版本没有任何黑客

EDIT2

I have tried run this app on my cousins mob (its SE, but another model) and it worked without any problem. As there isnt android update for my phone, Im trying to to "repair" it through original "Sony pc companion" software. I hope it will work after it as I guess it is not possible to downgrade the android version without any "hack"

我试图升级,甚至降级固件我的手机。一切照旧。我正在考虑写在客户支持或XDA论坛,并要求任何人使用相同的手机,试图运行它。

I have tried to upgrade and even downgrade firmware on my mobile. Nothing has changed. I'm considering writing on customer support or XDA forum and ask anybody with the same phone to try to run it.

推荐答案

开发它一步一步来。 从缺省值开始。

Develop it step by step. Begin from the default values.

mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
//Use values from available Camera preview sizes 
mMediaRecorder.setVideoSize(mCameraPreview.getPreviewWidth(), mCameraPreview.getPreviewHeight());
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

你仍然有错误,如果你不指定视频大小。 如果你没有执行管理preVIEW尺寸。有固定的大小来试试,它应该工作:

You'll still have errors if you don't specify video size. If you don't have implementation of managing preview sizes. Try it with fixed size, It should work:

mMediaRecorder.setVideoSize(320, 240);

这篇关于Android的捕捉视频mediaRecorder.start()失败-19的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆