Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QMediaFormat Class Reference

\inmodule QtMultimedia More...

#include <qmediaformat.h>

+ Inheritance diagram for QMediaFormat:
+ Collaboration diagram for QMediaFormat:

Public Types

enum  FileFormat {
  UnspecifiedFormat = -1 , WMV , AVI , Matroska ,
  MPEG4 , Ogg , QuickTime , WebM ,
  Mpeg4Audio , AAC , WMA , MP3 ,
  FLAC , Wave , LastFileFormat = Wave
}
 Describes the container format used in a multimedia file or stream. More...
 
enum class  AudioCodec {
  Unspecified = -1 , MP3 , AAC , AC3 ,
  EAC3 , FLAC , DolbyTrueHD , Opus ,
  Vorbis , Wave , WMA , ALAC ,
  LastAudioCodec = ALAC
}
 \qmlproperty enumeration QtMultimedia::mediaFormat::fileFormat More...
 
enum class  VideoCodec {
  Unspecified = -1 , MPEG1 , MPEG2 , MPEG4 ,
  H264 , H265 , VP8 , VP9 ,
  AV1 , Theora , WMV , MotionJPEG ,
  LastVideoCodec = MotionJPEG
}
 \qmlproperty enumeration QtMultimedia::mediaFormat::audioCodec More...
 
enum  ConversionMode { Encode , Decode }
 In many cases, systems have asymmetric capabilities and can often decode more formats or codecs than can be encoded. More...
 
enum  ResolveFlags { NoFlags , RequiresVideo }
 Describes the requirements for resolving a suitable format for QMediaRecorder. More...
 

Public Member Functions

 QMediaFormat (FileFormat format=UnspecifiedFormat)
 \qmlproperty enumeration QtMultimedia::mediaFormat::videoCodec
 
 ~QMediaFormat ()
 Destroys the QMediaFormat object.
 
 QMediaFormat (const QMediaFormat &other) noexcept
 Constructs a QMediaFormat object by copying from other.
 
QMediaFormatoperator= (const QMediaFormat &other) noexcept
 Copies other into this QMediaFormat object.
 
 QMediaFormat (QMediaFormat &&other) noexcept=default
 Constructs a QMediaFormat objects by moving from other.
 
void swap (QMediaFormat &other) noexcept
 Swaps the media format with other.
 
FileFormat fileFormat () const
 
void setFileFormat (FileFormat f)
 
void setVideoCodec (VideoCodec codec)
 Sets the video codec to codec.
 
VideoCodec videoCodec () const
 Returns the video codec used in this format.
 
void setAudioCodec (AudioCodec codec)
 Sets the audio codec to codec.
 
AudioCodec audioCodec () const
 Returns the audio codec used in this format.
 
Q_INVOKABLE bool isSupported (ConversionMode mode) const
 Returns true if Qt Multimedia can encode or decode this format, depending on mode.
 
QMimeType mimeType () const
 Returns the \l{MIME type} for the file format used in this media format.
 
Q_INVOKABLE QList< FileFormatsupportedFileFormats (ConversionMode m)
 \qmlmethod list<FileFormat> QtMultimedia::mediaFormat::supportedFileFormats(conversionMode) Returns a list of file formats for the audio and video codec indicated by {conversionMode}.
 
Q_INVOKABLE QList< VideoCodecsupportedVideoCodecs (ConversionMode m)
 \qmlmethod list<VideoCodec> QtMultimedia::mediaFormat::supportedVideoCodecs(conversionMode) Returns a list of video codecs for the chosen file format and audio codec (conversionMode).
 
Q_INVOKABLE QList< AudioCodecsupportedAudioCodecs (ConversionMode m)
 \qmlmethod list<AudioCodec> QtMultimedia::mediaFormat::supportedAudioFormats(conversionMode) Returns a list of audio codecs for the chosen file format and video codec (conversionMode).
 
bool operator== (const QMediaFormat &other) const
 Returns true if other is equal to the current media format, otherwise returns false.
 
bool operator!= (const QMediaFormat &other) const
 Returns true if other is not equal to the current media format, otherwise returns false.
 
void resolveForEncoding (ResolveFlags flags)
 Resolves the format, based on flags, to a format that is supported by QMediaRecorder.
 

Static Public Member Functions

static Q_INVOKABLE QString fileFormatName (FileFormat fileFormat)
 \qmlmethod string QtMultimedia::mediaFormat::fileFormatName(fileFormat) Returns a string based name for fileFormat.
 
static Q_INVOKABLE QString audioCodecName (AudioCodec codec)
 \qmlmethod string QtMultimedia::mediaFormat::audioCodecName(codec) Returns a string based name for codec.
 
static Q_INVOKABLE QString videoCodecName (VideoCodec codec)
 \qmlmethod string QtMultimedia::mediaFormat::videoCodecName(codec) Returns a string based name for codec.
 
static Q_INVOKABLE QString fileFormatDescription (QMediaFormat::FileFormat fileFormat)
 \qmlmethod string QtMultimedia::mediaFormat::fileFormatDescription(fileFormat) Returns a description for fileFormat.
 
static Q_INVOKABLE QString audioCodecDescription (QMediaFormat::AudioCodec codec)
 \qmlmethod string QtMultimedia::mediaFormat::audioCodecDescription(codec) Returns a description for codec.
 
static Q_INVOKABLE QString videoCodecDescription (QMediaFormat::VideoCodec codec)
 \qmlmethod string QtMultimedia::mediaFormat::videoCodecDescription(codec) Returns a description for codec.
 

Protected Attributes

FileFormat fmt
 
AudioCodec audio = AudioCodec::Unspecified
 
VideoCodec video = VideoCodec::Unspecified
 
QExplicitlySharedDataPointer< QMediaFormatPrivated
 

Properties

FileFormat fileFormat
 The file (container) format of the media.
 
AudioCodec audioCodec
 The audio codec of the media.
 
VideoCodec videoCodec
 The video codec of the media.
 

Friends

class QMediaFormatPrivate
 

Detailed Description

\inmodule QtMultimedia

Describes an encoding format for a multimedia file or stream.

Since
6.2

QMediaFormat describes an encoding format for a multimedia file or stream.

You can check whether a certain media format can be used for encoding or decoding using QMediaFormat.

Definition at line 18 of file qmediaformat.h.

Member Enumeration Documentation

◆ AudioCodec

enum class QMediaFormat::AudioCodec
strong

\qmlproperty enumeration QtMultimedia::mediaFormat::fileFormat

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

\table \header

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

Describes the audio codec used in multimedia file or stream.

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

\omitvalue LastAudioCodec

Enumerator
Unspecified 
MP3 
AAC 
AC3 
EAC3 
FLAC 
DolbyTrueHD 
Opus 
Vorbis 
Wave 
WMA 
ALAC 
LastAudioCodec 

Definition at line 47 of file qmediaformat.h.

◆ ConversionMode

In many cases, systems have asymmetric capabilities and can often decode more formats or codecs than can be encoded.

This enum describes the requested conversion mode to be used when checking whether a certain file format or codec is supported.

\value Encode Used to check whether a certain file format or codec can be encoded. \value Decode Used to check whether a certain file format or codec can be decoded.

See also
supportedFileFormats, supportedAudioCodecs, supportedVideoCodecs
Enumerator
Encode 
Decode 

Definition at line 81 of file qmediaformat.h.

◆ FileFormat

Describes the container format used in a multimedia file or stream.

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

\omitvalue LastFileFormat

Enumerator
UnspecifiedFormat 
WMV 
AVI 
Matroska 
MPEG4 
Ogg 
QuickTime 
WebM 
Mpeg4Audio 
AAC 
WMA 
MP3 
FLAC 
Wave 
LastFileFormat 

Definition at line 26 of file qmediaformat.h.

◆ ResolveFlags

Describes the requirements for resolving a suitable format for QMediaRecorder.

\value NoFlags No requirements \value RequiresVideo A video codec is required

See also
resolveForEncoding()
Enumerator
NoFlags 
RequiresVideo 

Definition at line 87 of file qmediaformat.h.

◆ VideoCodec

enum class QMediaFormat::VideoCodec
strong

\qmlproperty enumeration QtMultimedia::mediaFormat::audioCodec

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

\table \header

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

Describes the video coded used in multimedia file or stream.

\value VP8 \l{VP8} \value MPEG2 \l{MPEG-2} \value MPEG1 \l{MPEG-1} \value WMV \l{Windows Media Video} \value H265 \l{High Efficiency Video Coding (HEVC)} \value H264 \l{Advanced Video Coding} \value MPEG4 \l{MPEG-4} \value AV1 \l{AOMedia Video 1} \value MotionJPEG \l{MotionJPEG} \value VP9 \l{VP9} \value Theora \l{Theora} \value Unspecified Video codec not specified

\omitvalue LastVideoCodec

Enumerator
Unspecified 
MPEG1 
MPEG2 
MPEG4 
H264 
H265 
VP8 
VP9 
AV1 
Theora 
WMV 
MotionJPEG 
LastVideoCodec 

Definition at line 64 of file qmediaformat.h.

Constructor & Destructor Documentation

◆ QMediaFormat() [1/3]

QMediaFormat::QMediaFormat ( FileFormat format = UnspecifiedFormat)

\qmlproperty enumeration QtMultimedia::mediaFormat::videoCodec

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

\table \header

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

Constructs a QMediaFormat object for format.

Definition at line 354 of file qmediaformat.cpp.

◆ ~QMediaFormat()

QMediaFormat::~QMediaFormat ( )
default

Destroys the QMediaFormat object.

◆ QMediaFormat() [2/3]

QMediaFormat::QMediaFormat ( const QMediaFormat & other)
defaultnoexcept

Constructs a QMediaFormat object by copying from other.

◆ QMediaFormat() [3/3]

QMediaFormat::QMediaFormat ( QMediaFormat && other)
defaultnoexcept

Constructs a QMediaFormat objects by moving from other.

Member Function Documentation

◆ audioCodec()

AudioCodec QMediaFormat::audioCodec ( ) const
inline

Returns the audio codec used in this format.

See also
setAudioCodec(), QMediaFormat::AudioCodec

Definition at line 115 of file qmediaformat.h.

◆ audioCodecDescription()

QString QMediaFormat::audioCodecDescription ( QMediaFormat::AudioCodec codec)
static

\qmlmethod string QtMultimedia::mediaFormat::audioCodecDescription(codec) Returns a description for codec.

Returns a description for codec.

Definition at line 673 of file qmediaformat.cpp.

◆ audioCodecName()

QString QMediaFormat::audioCodecName ( QMediaFormat::AudioCodec codec)
static

\qmlmethod string QtMultimedia::mediaFormat::audioCodecName(codec) Returns a string based name for codec.

Returns a string based name for codec.

Definition at line 589 of file qmediaformat.cpp.

◆ fileFormat()

FileFormat QMediaFormat::fileFormat ( ) const
inline

Definition at line 108 of file qmediaformat.h.

◆ fileFormatDescription()

QString QMediaFormat::fileFormatDescription ( QMediaFormat::FileFormat fileFormat)
static

\qmlmethod string QtMultimedia::mediaFormat::fileFormatDescription(fileFormat) Returns a description for fileFormat.

Returns a description for fileFormat.

Definition at line 643 of file qmediaformat.cpp.

◆ fileFormatName()

QString QMediaFormat::fileFormatName ( QMediaFormat::FileFormat fileFormat)
static

\qmlmethod string QtMultimedia::mediaFormat::fileFormatName(fileFormat) Returns a string based name for fileFormat.

Returns a string based name for fileFormat.

Definition at line 559 of file qmediaformat.cpp.

◆ isSupported()

bool QMediaFormat::isSupported ( ConversionMode mode) const

Returns true if Qt Multimedia can encode or decode this format, depending on mode.

Definition at line 444 of file qmediaformat.cpp.

◆ mimeType()

QMimeType QMediaFormat::mimeType ( ) const

Returns the \l{MIME type} for the file format used in this media format.

Definition at line 453 of file qmediaformat.cpp.

◆ operator!=()

bool QMediaFormat::operator!= ( const QMediaFormat & other) const
inline

Returns true if other is not equal to the current media format, otherwise returns false.

Definition at line 134 of file qmediaformat.h.

◆ operator=()

QMediaFormat & QMediaFormat::operator= ( const QMediaFormat & other)
defaultnoexcept

Copies other into this QMediaFormat object.

Moves other into this QMediaFormat objects.

◆ operator==()

bool QMediaFormat::operator== ( const QMediaFormat & other) const

Returns true if other is equal to the current media format, otherwise returns false.

Definition at line 730 of file qmediaformat.cpp.

◆ resolveForEncoding()

void QMediaFormat::resolveForEncoding ( ResolveFlags flags)

Resolves the format, based on flags, to a format that is supported by QMediaRecorder.

This method tries to find the best possible match for unspecified settings. Settings that are not supported by the recorder will be modified to the closest match that is supported.

When resolving, priority is given in the following order: \list 1

  • File format
  • Video codec
  • Audio codec \endlist

Definition at line 767 of file qmediaformat.cpp.

◆ setAudioCodec()

void QMediaFormat::setAudioCodec ( AudioCodec codec)
inline

Sets the audio codec to codec.

See also
audioCodec(), QMediaFormat::AudioCodec

Definition at line 114 of file qmediaformat.h.

◆ setFileFormat()

void QMediaFormat::setFileFormat ( FileFormat f)
inline

Definition at line 109 of file qmediaformat.h.

◆ setVideoCodec()

void QMediaFormat::setVideoCodec ( VideoCodec codec)
inline

Sets the video codec to codec.

See also
videoCodec(), QMediaFormat::VideoCodec

Definition at line 111 of file qmediaformat.h.

◆ supportedAudioCodecs()

QList< QMediaFormat::AudioCodec > QMediaFormat::supportedAudioCodecs ( QMediaFormat::ConversionMode m)

\qmlmethod list<AudioCodec> QtMultimedia::mediaFormat::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

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

To get all supported audio codecs, run this query on a default constructed QMediaFormat.

See also
QMediaFormat::ConversionMode

Definition at line 546 of file qmediaformat.cpp.

◆ supportedFileFormats()

QList< QMediaFormat::FileFormat > QMediaFormat::supportedFileFormats ( QMediaFormat::ConversionMode m)

\qmlmethod list<FileFormat> QtMultimedia::mediaFormat::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

Returns a list of file formats for the audio and video codec indicated by {m}.

To get all supported file formats, run this query on a default constructed QMediaFormat.

See also
QMediaFormat::ConversionMode

Definition at line 494 of file qmediaformat.cpp.

◆ supportedVideoCodecs()

QList< QMediaFormat::VideoCodec > QMediaFormat::supportedVideoCodecs ( QMediaFormat::ConversionMode m)

\qmlmethod list<VideoCodec> QtMultimedia::mediaFormat::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

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

To get all supported video codecs, run this query on a default constructed MediaFormat.

See also
QMediaFormat::ConversionMode

Definition at line 520 of file qmediaformat.cpp.

◆ swap()

void QMediaFormat::swap ( QMediaFormat & other)
inlinenoexcept

Swaps the media format with other.

Definition at line 100 of file qmediaformat.h.

◆ videoCodec()

VideoCodec QMediaFormat::videoCodec ( ) const
inline

Returns the video codec used in this format.

See also
setVideoCodec(), QMediaFormat::VideoCodec

Definition at line 112 of file qmediaformat.h.

◆ videoCodecDescription()

QString QMediaFormat::videoCodecDescription ( QMediaFormat::VideoCodec codec)
static

\qmlmethod string QtMultimedia::mediaFormat::videoCodecDescription(codec) Returns a description for codec.

Returns a description for codec.

Definition at line 700 of file qmediaformat.cpp.

◆ videoCodecName()

QString QMediaFormat::videoCodecName ( QMediaFormat::VideoCodec codec)
static

\qmlmethod string QtMultimedia::mediaFormat::videoCodecName(codec) Returns a string based name for codec.

Returns a string based name for codec.

Definition at line 616 of file qmediaformat.cpp.

Friends And Related Symbol Documentation

◆ QMediaFormatPrivate

friend class QMediaFormatPrivate
friend

Definition at line 140 of file qmediaformat.h.

Member Data Documentation

◆ audio

AudioCodec QMediaFormat::audio = AudioCodec::Unspecified
protected

Definition at line 142 of file qmediaformat.h.

◆ d

Definition at line 144 of file qmediaformat.h.

◆ fmt

FileFormat QMediaFormat::fmt
protected

Definition at line 141 of file qmediaformat.h.

◆ video

VideoCodec QMediaFormat::video = VideoCodec::Unspecified
protected

Definition at line 143 of file qmediaformat.h.

Property Documentation

◆ audioCodec

AudioCodec QMediaFormat::audioCodec
readwrite

The audio codec of the media.

See also
QMediaFormat::AudioCodec

Definition at line 22 of file qmediaformat.h.

◆ fileFormat

FileFormat QMediaFormat::fileFormat
readwrite

The file (container) format of the media.

See also
QMediaFormat::FileFormat

Definition at line 21 of file qmediaformat.h.

◆ videoCodec

VideoCodec QMediaFormat::videoCodec
readwrite

The video codec of the media.

See also
QMediaFormat::VideoCodec

Definition at line 23 of file qmediaformat.h.


The documentation for this class was generated from the following files: