2017-06-22 86 views
0

我試圖使用MediaRecorder類創建遊戲視頻,並且需要在錄製完成後將視頻文件與另一個視頻合併。問題是由MediaRecorder創建的每個視頻都有一個不穩定的幀速率雖然我將它設置爲24,它永遠是與像39.542004 20.xxx一些其他的號碼等,這裏是我的代碼:Android MediaRecorder創建視頻幀率不穩定

 mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
     mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE); 
     mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
     mMediaRecorder.setOutputFile(outPutDir.getPath() + "/" + fileName); 
     mMediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT); 
     mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); 
     mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); 
     mMediaRecorder.setAudioEncodingBitRate(44100); 
     mMediaRecorder.setVideoEncodingBitRate(3000 * 1000); 
     mMediaRecorder.setVideoFrameRate(24); 

我需要我的視頻幀速率是穩定的24或30,所以我可以在其後追加另一個視頻,任何幫助非常感謝!

回答

0

有這個在這裏另一篇文章的一些信息:()Forcing the camera in Android to deliver 30 FPS

調用getSupportedPreviewFpsRange會給你什麼樣的攝像頭的範圍可以瞭解更多信息,然後相應地設置您的建議的幀速率。

請注意,對硬件的請求往往只是建議。相機可自動調整幀速率,因爲它適應新的照明和對焦設置。 (有關FPS調整的更多信息,請參閱此處Why does camera frame rate fluctuate when fusing another sensor?

嘗試指示每個相機設置,以便相機不再進行自動調整以更好地改善照片質量,並查看FPS如何受到影響。不幸的是,爲手機攝像頭設置特定的FPS速率不可能保證FPS不會消除相機更改的其他變量。

+0

感謝貝利,但我沒有在這裏使用設備的相機,我試圖記錄表面(屏幕),我不確定那些相機限制仍然適用於那裏 – RandomCouch