The Kotlin camera2 API rear video capture Android development tutorial describes how to create a camera capture session for recording the rear camera.
This Kotlin tutorial follows on from the MediaRecorder episode.
In this Kotlin on Android tutorial we will cover:
- Creating a simple state machine for record status
- Implementing a record capture session
- Starting and stopping the media recorder
- Starting and stopping the chronometer
- Rear Camera Record
- Round preview thumbnail
- Sharing Uri with ViewModel
- Video Playback with ExoPlayer
- Video PIP
- Front Camera Record (Premium)
- Video Record with Audio (Premium)
- Replace TextureView with SurfaceView (Premium)
Disclaimer, it is recommended to follow this Kotlin on Android tutorial series using a Google Pixel or Nexus device.
Please do not try it with the Android Emulator. Bugs have also been observed in camera stacks of none Google devices, which may be exposed by this tutorial series.
In this Kotlin on Android development tutorial we described how to create a video recording session.
A new camera capture session needed to be created with the CameraDevice.TEMPLATE_RECORD. Then the TextureView and MediaRecorder surfaces were added to the CaptureRequest builder as well as included as part of the capture session creation.
If the camera capture session is successfully configured a CameraCaptureSession object will be available.
Which can be used to start a repeating request.
A flag was added to save the record state. Which was used by the button on click listener to decide whether to start or stop the MediaRecorder.
The following Kotlin on Android tutorial will describe how to create a round thumbnail from a video.