80,337
社区成员
发帖
与我相关
我的任务
分享
recorder = new MediaRecorder();
recorder.setPreviewDisplay(surfaceHolder.getSurface());
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//set the Output Format
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//set the Video Size
recorder.setVideoSize(176,144);
//set the Frame rate
recorder.setVideoFrameRate(15);
//Set the Video Encoder
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
//Set the Audio Encoder
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
recorder.setOutputFile(myRecAudioFile.getAbsolutePath());
recorder.prepare();
recorder.start();
03-22 22:39:41.120: WARN/StagefrightRecorder(662): Intended video encoding frame rate (15 fps) is too small and will be set to (27 fps)
03-22 22:39:41.380: ERROR/VENC_ENC(662): Bitrate 192000
/**
* Uses the settings from a CamcorderProfile object for recording. This method should
* be called after the video AND audio sources are set, and before setOutputFile().
* 使用来自记录CamcorderProfile对象的设置。这种方法应该调用在
* 被命名后的视频和音频源设置和setOutputFile()之前。
* @param profile the CamcorderProfile to use
* @see android.media.CamcorderProfile
*/
/**
* Uses the settings from a CamcorderProfile object for recording. This method should
* be called after the video AND audio sources are set, and before setOutputFile().
* 使用来自记录CamcorderProfile对象的设置。这种方法应该调用在
* 被命名后的视频和音频源设置和setOutputFile()之前。
* @param profile the CamcorderProfile to use
* @see android.media.CamcorderProfile
*/
public void setProfile(CamcorderProfile profile) {
setOutputFormat(profile.fileFormat); //设置在录制过程中产生的输出文件格式
setVideoFrameRate(profile.videoFrameRate); //设置视频的帧速率,以被捕获setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight); //设置宽度和高度的视频捕获
setVideoEncodingBitRate(profile.videoBitRate); //设置视频编码录音比特率
setAudioEncodingBitRate(profile.audioBitRate);//设置音频编码录音比特率
setAudioChannels(profile.audioChannels);//设置录制的音频通道数
setAudioSamplingRate(profile.audioSampleRate); //设置音频采样率记录
setVideoEncoder(profile.videoCodec); //设置视频编码器可用于录制。如果这个方法不叫,输出文件将不包含视频
setAudioEncoder(profile.audioCodec); //设置音频编码器可用于录制 如果是录音一定要设置哦不然没有音频哦
}
recorder = new MediaRecorder();
recorder.setPreviewDisplay(surfaceHolder.getSurface());
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//replacement
CamcorderProfile cpLow = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
recorder.setProfile(cpLow);
recorder.setOutputFile(myRecAudioFile.getAbsolutePath());
recorder.prepare();
recorder.start();