MediaRecorder,第一帧空白

时间:2013-12-03 20:54:03

标签: android camera video-capture mediarecorder video-recording

我正在尝试开发一个简单的录像机

我初始化Camera,然后点击按钮我运行Runnable准备MediaRecorder

public void run() {
    mCamera.unlock();
    mMediaRecorder = new MediaRecorder();
    mMediaRecorder.setCamera(mCamera);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

    mMediaRecorder.setVideoSize(320, 240);

    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setOutputFile(mSomeFile); 

    mMediaRecorder.setMaxDuration(MAX_DURATION);
    mMediaRecorder.setOrientationHint(90);


    try {
        mMediaRecorder.prepare();
        mMediaRecorder.start();
    } catch (Exception e) {
        e.printStackTrace();
    } 
}

每件事都运行正常,但实际输出视频在开头包含一些空白帧。它可能是硬件问题还是需要代码优化?

0 个答案:

没有答案