我想從相機捕捉時間流逝。我已經與視頻錄製合作,並且運行良好。但是當我嘗試錄製時間延遲視頻時,它出錯了。從Android相機捕捉時間流逝
這裏是我的代碼,我想:
mMediaRecorder = new MediaRecorder();
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
// Step 2: Set sources
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set a CamcorderProfile (requires API Level 8 or higher)
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_HIGH));
// Step 4: Set output file
mMediaRecorder.setOutputFile(String.valueOf(GeneralUtils.getOutputMediaFile(MEDIA_TYPE_VIDEO)));
// Step 5: Set the preview output
mMediaRecorder.setPreviewDisplay(this.getHolder().getSurface());
// Step 6: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
錄製視頻後,當我檢查它的大小是0.00B
並不能播放此視頻。爲什麼這不錄製視頻。
我試了更多,發現一些東西,如果你用CamcorderProfile.QUALITY_HIGH
代替CamcorderProfile.QUALITY_TIME_LAPSE_HIGH
它開始工作。我搜索了一下,發現原因是可能是你的設備不支持QUALITY_TIME_LAPSE_HIGH
。但是,當我打開本機相機應用程序並點擊記錄時間推移視頻時,這是一件奇怪的事情,它工作正常,這意味着我的設備支持QUALITY_TIME_LAPSE_HIGH
。
我的問題是,爲什麼它不適合我的應用程序。我的代碼中有任何錯誤嗎?你能不能讓我知道。
不確定這是否會成爲運行時權限問題? – SripadRaj
不是這不是任何權限問題。我已經檢查了它 – PakDeveloper
對於時間推移視頻,你有「setCaptureRate」嗎? –