这似乎是一个愚蠢的问题,我整晚都在研究这个问题,但无法从我的手机上录制 webm 视频。
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM);
//mMediaRecorder.setOutputFormat(outFormat);
//CamcorderProfile camPro = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_480P);
//camPro.fileFormat = MediaRecorder.OutputFormat.WEBM;
//camPro.videoFrameRate = 30;
mMediaRecorder.setCaptureRate(30f);
//camPro.videoFrameWidth = 360;
//camPro.videoFrameHeight = 640;
//camPro.videoBitRate = 2000000;
//camPro.audioCodec = MediaRecorder.AudioEncoder.VORBIS;
mMediaRecorder.setVideoSize(640,360);
mMediaRecorder.setVideoEncodingBitRate(2000000);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.VORBIS);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.VP8);
//camPro.videoCodec = MediaRecorder.VideoEncoder.VP8;
mMediaRecorder.setVideoFrameRate(30);
//mMediaRecorder.setProfile(camPro);
我已经评论了摄像机配置文件行,因为我想只有一个必须使用。我还看到一条注释说它需要 API 级别 21,所以我在我的 moto G 上使用棒棒糖 5.0.2。
我得到的错误是Camera dead Error 100。有时会发生媒体recorder.prepare(),但随后媒体recorder.start()会引发错误。我对应该做什么感到困惑。一旦我没有错误。但我只有一个 6.19KB 的文件,无法播放。