android 视频录制源代码
public void recorder() { try { myRecAudioFile = File.createTempFile("video", ".3gp",dir);//创建临时文件 recorder.setPreviewDisplay(mSurfaceHolder.getSurface());//预览 recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);//视频源 recorder.setAudioSo urce(MediaRecorder.AudioSource.MIC); //录音源为麦克风 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);//输出格式为3gp recorder.setVideoSize(800, 480);//视频尺寸 recorder.setVideoFrameRate(15);//视频帧频率 recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);//视频编码 recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);//音频编码 recorder.setMaxDuration(10000);//最大期限 recorder.setOutputFile(myRecAudioFile.getAbsolutePath());//保存路径 recorder.prepare(); recorder.start(); } catch (IOException e) { e.printStackTrace(); } } urce(MediaRecorder.AudioSource.MIC); //录音源为麦克风 recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);//输出格式为3gp recorder.setVideoSize(800, 480);//视频尺寸 recorder.setVideoFrameRate(15);//视频帧频率 recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);//视频编码 recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);//音频编码 recorder.setMaxDuration(10000);//最大期限 recorder.setOutputFile(myRecAudioFile.getAbsolutePath());//保存路径 recorder.prepare(); recorder.start(); } catch (IOException e) { e.printStackTrace(); } }
用户评论