Android MediaRecorder slowmotion
时间: 2023-12-24 15:05:03 浏览: 131
To record slow motion videos using MediaRecorder in Android, you need to set the video frame rate to a higher value than the default frame rate. Here's an example code snippet to record slow motion videos:
```java
MediaRecorder recorder = new MediaRecorder();
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
// set the slow motion frame rate
recorder.setVideoFrameRate(60);
// set the video output file path
recorder.setOutputFile(outputFilePath);
// start the recording
recorder.prepare();
recorder.start();
```
In the above code snippet, we set the video frame rate to 60 frames per second, which will record a slow motion video. You can experiment with different frame rates to achieve the desired slow motion effect.
阅读全文