Created
September 7, 2015 12:51
-
-
Save masayuki610930/7c6459341b360dc96efb to your computer and use it in GitHub Desktop.
AndroidのMediaRecorderを使った録画・録音の設定
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MediaRecorder mMdeiaRecorder = new MediaRecorder(); | |
// 入力ソースの指定 | |
// ファイルフォーマットの指定 | |
// エンコーダー の指定の順でなければならない | |
// 入力ソース | |
// 録画の入力ソースを指定 | |
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); | |
// 音声の入力ソースを指定 | |
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); | |
// フォーマット | |
// ファイルフォーマットを指定 | |
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); | |
// エンコーダー | |
// ビデオエンコーダを指定 | |
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP); | |
// 音声エンコーダを指定 | |
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); | |
// 各種設定 | |
// 出力するファイルパスを指定 | |
mMediaRecorder.setOutputFile(filePath); | |
// 動画のフレームレートを指定 | |
mMediaRecorder.setVideoFrameRate(frameRate); | |
// 動画のサイズを指定 | |
mMediaRecorder.setVideoSize(width, height); | |
// プレビューに利用するサーフェイスを指定する | |
mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); | |
// 録画準備 | |
try { | |
mMediaRecorder.prepare(); | |
} | |
catch (final Exception e) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブログに書きました