- Qt 6.11
- Qt Multimedia
- QML Types
- mediaFormat
- Qt 6.11.0 Reference Documentation

# mediaFormat QML Value Type

MediaFormat describes the format of a media file. More...

Import Statement: | `import QtMultimedia`

## Properties

- audioCodec : enumeration
- fileFormat : enumeration
- videoCodec : enumeration

## Methods

- string audioCodecDescription(codec)
- string audioCodecName(codec)
- string fileFormatDescription(fileFormat)
- string fileFormatName(fileFormat)
- list<AudioCodec> supportedAudioFormats(conversionMode)
- list<FileFormat> supportedFileFormats(conversionMode)
- list<VideoCodec> supportedVideoCodecs(conversionMode)
- string videoCodecDescription(codec)
- string videoCodecName(codec)

## Detailed Description

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.

See also MediaRecorder and CaptureSession.

## Property Documentation

### audioCodec : enumeration

Describes the audio codec used in multimedia file or stream. It can take one of the following values:

Property value | Description
--- | ---
MediaFormat.WMA | Windows Media Audio
MediaFormat.AC3 | Dolby Digital
MediaFormat.AAC | Advanced Audio Coding
MediaFormat.ALAC | Apple Lossless Audio Codec
MediaFormat.DolbyTrueHD | Dolby TrueHD
MediaFormat.EAC3 | Dolby Digital Plus (EAC3)
MediaFormat.MP3 | MPEG-1 Audio Layer III or MPEG-2 Audio Layer III
MediaFormat.Wave | Waveform Audio File Format
MediaFormat.Vorbis | Ogg Vorbis
MediaFormat.FLAC | Free Lossless Audio Codec
MediaFormat.Opus | Opus Audio Format
MediaFormat.Unspecified | Unspecified codec

### fileFormat : enumeration

Describes the container format used in a multimedia file or stream. It can take one of the following values:

Property value | Description
--- | ---
MediaFormat.WMA | Windows Media Audio
MediaFormat.AAC | Advanced Audio Coding
MediaFormat.Matroska | Matroska (MKV)
MediaFormat.WMV | Windows Media Video
MediaFormat.MP3 | MPEG-1 Audio Layer III or MPEG-2 Audio Layer III
MediaFormat.Wave | Waveform Audio File Format
MediaFormat.Ogg | Ogg
MediaFormat.MPEG4 | MPEG-4
MediaFormat.AVI | Audio Video Interleave
MediaFormat.QuickTime | QuickTime
MediaFormat.WebM | WebM
MediaFormat.Mpeg4Audio | MPEG-4 Part 3 or MPEG-4 Audio (formally ISO/IEC 14496-3)
MediaFormat.FLAC | Free Lossless Audio Codec
MediaFormat.UnspecifiedFormat | The format is unspecified.

### videoCodec : enumeration

Describes the video codec used in multimedia file or stream. It can take one of the following values:

Property value | Description
--- | ---
MediaFormat.VP8 | VP8
MediaFormat.MPEG2 | MPEG-2
MediaFormat.MPEG1 | MPEG-1
MediaFormat.WMV | Windows Media Video
MediaFormat.H265 | High Efficiency Video Coding (HEVC)
MediaFormat.H264 | Advanced Video Coding
MediaFormat.MPEG4 | MPEG-4
MediaFormat.AV1 | AOMedia Video 1
MediaFormat.MotionJPEG | MotionJPEG
MediaFormat.VP9 | VP9
MediaFormat.Theora | Theora
MediaFormat.Unspecified | Video codec not specified

## Method Documentation

### string audioCodecDescription(codec)

Returns a description for codec.

### string audioCodecName(codec)

Returns a string based name for codec.

### string fileFormatDescription(fileFormat)

Returns a description for fileFormat.

### string fileFormatName(fileFormat)

Returns a string based name for fileFormat.

### list<AudioCodec> supportedAudioFormats(conversionMode)

Returns a list of audio codecs for the chosen file format and video codec (conversionMode).

To get all supported audio codecs, run this query on a default constructed MediaFormat. To get a list of supported audio codecs for a specific combination of a file format and a video codec, you can set the fileFormat and videoCodec properties before running this query.

See also QMediaFormat::ConversionMode.

### list<FileFormat> supportedFileFormats(conversionMode)

Returns a list of file formats for the audio and video codec indicated by conversionMode.

To get all supported file formats, run this query on a default constructed MediaFormat. To get a list of file formats supporting a specific combination of an audio and video codec, you can set the audioCodec and videoCodec properties before running this query.

See also QMediaFormat::ConversionMode.

### list<VideoCodec> supportedVideoCodecs(conversionMode)

Returns a list of video codecs for the chosen file format and audio codec (conversionMode).

To get all supported video codecs, run this query on a default constructed MediaFormat. To get a list of supported video codecs for a specific combination of a file format and an audio codec, you can set the fileFormat and audioCodec properties before running this query.

See also QMediaFormat::ConversionMode.

### string videoCodecDescription(codec)

Returns a description for codec.

### string videoCodecName(codec)

Returns a string based name for codec.