The MediaFormat type describes the format of a media file. It contains three properties that describe the file type and the audio and video codecs that are being used.
MediaFormat can be used to specify the type of file that should be created by a MediaRecorder . The snippet below shows an example that sets up the recorder to create an mpeg4 video with AAC encoded audio and H265 video:
CaptureSession { ... // setup inputs MediaRecorder { mediaFormat { fileFormat: MediaFormat.MPEG4 audioCodec: MediaFormat.AudioCodec.AAC videoCodec: MediaFormat.VideoCodec.H265 } } }
If the specified mediaFormat is not supported, the MediaRecorder will automatically try to find the best possible replacement format and use that instead.
另请参阅 MediaRecorder and CaptureSession .