MediaRecorder
Encodes media from a registered source and writes it to a file.
Register the recorder with a mixer before recording. Attach capture sources and start the mixer before using this example. The output path must be writable by the application.
val recorder = MediaRecorder(context)
mixer.registerOutput(recorder)
val output = java.io.File(context.filesDir, "output.mp4")
recorder.startRecording(output.absolutePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4)
// After capturing the desired media:
recorder.stopRecording()
mixer.unregisterOutput(recorder)Content copied to clipboard
Properties
Link copied to clipboard
Specifies the audio codec settings.
Link copied to clipboard
A weak reference to the registered media source, or null when detached.
Link copied to clipboard
Whether this recorder is currently recording audio and video.
Link copied to clipboard
Specifies the video codec settings.
Functions
Link copied to clipboard
Receives a media buffer from the source. Consume or copy its payload before it is reused.
Link copied to clipboard
Starts recording to a file descriptor. Requires Android 8.0 (API 26) or later.
Starts recording to a file path.
Link copied to clipboard
Stops recording and finalizes the output file.