1

我正在尝试开始录制视频,但程序在“recorder.start();”行中崩溃了。该程序在Huawei D1 (8 Mpx) 上是稳定的,但在HTC Desure C (5 Mpx) 上程序已经开始出现错误

错误:

W/dalvikvm(18833): threadid=1: thread exiting with uncaught exception (group=0x40a8b228)
E/AndroidRuntime(18833): FATAL EXCEPTION: main
E/AndroidRuntime(18833): java.lang.RuntimeException: start failed.

代码:

    public void startRec(SurfaceHolder surfaceHolder, String VideoName) {
        camera.stopPreview();
        camera.unlock();
        recorder.setCamera(camera);
        setRecorderParams();
        recorder.setPreviewDisplay(surfaceHolder.getSurface());      
        recorder.setOutputFile(VideoName);
        try {
            recorder.prepare();
            recorder.start();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void setRecorderParams() {   
        recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
        recorder.setVideoEncodingBitRate(30000);
        recorder.setVideoSize(640, 480);
    }
4

1 回答 1

0

将正确的参数发布到记录器的解决方案。某些设备不提供某些视频编码器或输出格式。

视频编码器参数

于 2015-04-02T06:22:38.037 回答