5

我需要录制视频并保存它,但我在start()媒体记录器的方法上遇到错误:失败 - 19(这个错误应该是什么?文档中没有对此发表评论:()我正在与这个错误作斗争一天,我尝试了多个代码(谷歌教程,英特尔示例,......)我在网上找到了,但无法使它们中的任何一个工作。请帮我找出导致问题的原因。我什至开始怀疑我的手机(SE live,wt19i)是否能够录制视频(但默认相机应用程序工作正常)。真的,,有人知道我应该尝试/检查/修复什么吗?

这是我的录制代码:

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

这是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)

编辑:

我正在添加我的清单文件:

<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>

编辑2

我已经尝试我的堂兄弟 mob上运行这个应用程序(它的 SE,但另一个模型)并且它运行没有任何问题。由于我的手机没有安卓更新,我试图通过原始的“索尼电脑伴侣”软件“修复”它。我希望它会在它之后工作,因为我想如果没有任何“hack”就不可能降级 android 版本

编辑3

我曾尝试升级甚至降级手机上的固件。什么也没有变。我正在考虑在客户支持或 XDA 论坛上撰写文章,并请使用同一部手机的任何人尝试运行它。

4

2 回答 2

1

一步一步地开发它。从默认值开始。

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);

如果您不指定视频大小,您仍然会遇到错误。如果您没有管理预览大小的实现。尝试使用固定大小,它应该可以工作:

mMediaRecorder.setVideoSize(320, 240);
于 2013-04-19T07:18:55.997 回答
0

我找不到关于错误 -19 的文档。但是,看起来您并没有要求所有需要的权限。start failed错误有时是由于缺少权限:

尝试添加的可能权限是:

<uses-feature android:name="android.hardware.microphone"/>

<uses-permission android:name="android.permission.STORAGE" />
于 2012-12-06T00:06:07.983 回答