Skip to content

Instantly share code, notes, and snippets.

@masayuki610930
Created September 7, 2015 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masayuki610930/7c6459341b360dc96efb to your computer and use it in GitHub Desktop.
Save masayuki610930/7c6459341b360dc96efb to your computer and use it in GitHub Desktop.
AndroidのMediaRecorderを使った録画・録音の設定
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) {
}
@masayuki610930
Copy link
Author

ブログに書きました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment