是否有推荐的设置用于在Android中录制MP4格式的视频?

时间:2017-01-10 10:38:39

标签: android android-camera

我有录制MP4格式的选项,并使用MPEG_4作为输出格式,MPEG_4_SP作为视频编码。它目前正在工作,但我想知道编码是否可以改进。

我似乎无法找到推荐设置的相关资源。:

mVideoRecorder = new MediaRecorder();
mVideoRecorder.setCamera(mCamera);
mVideoRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mVideoRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mVideoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mVideoRecorder.setVideoSize(720, 480);

//anything higher than frame rate 20 results to black screen
mVideoRecorder.setVideoFrameRate(20); 
mVideoRecorder.setVideoEncodingBitRate(3000000);
mVideoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
mVideoRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);

// sampling rate for AMR_WB
mVideoRecorder.setAudioSamplingRate(16000); 

// allowed recording duration is 30 secs only... around 6mb file
mVideoRecorder.setMaxDuration(30000);

1 个答案:

答案 0 :(得分:0)

最后,在经过一系列的试验和错误之后,这对于android和转移到iphone时都有用。

        mVideoRecorder = new MediaRecorder();
        mVideoRecorder.setCamera(mCamera);
        mVideoRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
        mVideoRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mVideoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        mVideoRecorder.setVideoSize(720, 480);
        mVideoRecorder.setVideoEncodingBitRate(3000000);
        mVideoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
        mVideoRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        mVideoRecorder.setAudioSamplingRate(441000);
        mVideoRecorder.setMaxDuration(30000); // allowed recording is 30 seconds only
        mVideoRecorder.setPreviewDisplay(surfaceHolder.getSurface());
        mVideoRecorder.setOutputFile(uniqueOutFile);
        mVideoRecorder.prepare();
        mVideoRecorder.start();

注意:我使用VLC for android Information来研究在Android和iPhone上运行的MP4文件,并尝试生成相同的设置。