QMediaFormat 類

描述多媒體文件 (或流) 的編碼格式。 更多...

頭: #include <QMediaFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia

公共類型

枚舉類 AudioCodec { WMA, AC3, AAC, ALAC, DolbyTrueHD, …, Unspecified }
enum ConversionMode { Encode, Decode }
enum FileFormat { WMA, AAC, Matroska, WMV, MP3, …, UnspecifiedFormat }
enum ResolveFlags { NoFlags, RequiresVideo }
枚舉類 VideoCodec { VP8, MPEG2, MPEG1, WMV, H265, …, Unspecified }

特性

公共函數

QMediaFormat (QMediaFormat::FileFormat format = UnspecifiedFormat)
QMediaFormat (const QMediaFormat & other )
QMediaFormat (QMediaFormat && other )
~QMediaFormat ()
QMediaFormat::AudioCodec audioCodec () const
QMediaFormat::FileFormat fileFormat () const
bool isSupported (QMediaFormat::ConversionMode mode ) const
QMimeType mimeType () const
void resolveForEncoding (QMediaFormat::ResolveFlags flags )
void setAudioCodec (QMediaFormat::AudioCodec codec )
void setFileFormat (QMediaFormat::FileFormat f )
void setVideoCodec (QMediaFormat::VideoCodec codec )
QList<QMediaFormat::AudioCodec> supportedAudioCodecs (QMediaFormat::ConversionMode m )
QList<QMediaFormat::FileFormat> supportedFileFormats (QMediaFormat::ConversionMode m )
QList<QMediaFormat::VideoCodec> supportedVideoCodecs (QMediaFormat::ConversionMode m )
void swap (QMediaFormat & other )
QMediaFormat::VideoCodec videoCodec () const
bool operator!= (const QMediaFormat & other ) const
QMediaFormat & operator= (QMediaFormat && other )
QMediaFormat & operator= (const QMediaFormat & other )
bool operator== (const QMediaFormat & other ) const

靜態公共成員

QString audioCodecDescription (QMediaFormat::AudioCodec codec )
QString audioCodecName (QMediaFormat::AudioCodec codec )
QString fileFormatDescription (QMediaFormat::FileFormat fileFormat )
QString fileFormatName (QMediaFormat::FileFormat fileFormat )
QString videoCodecDescription (QMediaFormat::VideoCodec codec )
QString videoCodecName (QMediaFormat::VideoCodec codec )

詳細描述

QMediaFormat 描述多媒體文件 (或流) 的編碼格式。

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

成員類型文檔編製

enum class QMediaFormat:: AudioCodec

Describes the audio codec used in multimedia file or stream.

常量 描述
QMediaFormat::AudioCodec::WMA 9 WMA (Windows 媒體音頻)
QMediaFormat::AudioCodec::AC3 2 杜比數字
QMediaFormat::AudioCodec::AAC 1 AAC (高級音頻編碼)
QMediaFormat::AudioCodec::ALAC 10 ALAC (Apple 無損音頻編解碼器)
QMediaFormat::AudioCodec::DolbyTrueHD 5 杜比 TrueHD
QMediaFormat::AudioCodec::EAC3 3 杜比數字 + (EAC3)
QMediaFormat::AudioCodec::MP3 0 MPEG-1 音頻層 III (或 MPEG-2 音頻層 III)
QMediaFormat::AudioCodec::Wave 8 波形音頻文件格式
QMediaFormat::AudioCodec::Vorbis 7 Ogg Vorbis
QMediaFormat::AudioCodec::FLAC 4 FLAC (自由無損音頻編解碼器)
QMediaFormat::AudioCodec::Opus 6 Opus 音頻格式
QMediaFormat::AudioCodec::Unspecified -1 未指定編解碼器

enum QMediaFormat:: 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.

常量 描述
QMediaFormat::Encode 0 Used to check whether a certain file format or codec can be encoded.
QMediaFormat::Decode 1 Used to check whether a certain file format or codec can be decoded.

另請參閱 supportedFileFormats , supportedAudioCodecs ,和 supportedVideoCodecs .

enum QMediaFormat:: FileFormat

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

常量 描述
QMediaFormat::WMA 9 WMA (Windows 媒體音頻)
QMediaFormat::AAC 8 AAC (高級音頻編碼)
QMediaFormat::Matroska 2 Matroska (MKV)
QMediaFormat::WMV 0 WMV (Windows 媒體視頻)
QMediaFormat::MP3 10 MPEG-1 音頻層 III (或 MPEG-2 音頻層 III)
QMediaFormat::Wave 12 波形音頻文件格式
QMediaFormat::Ogg 4 Ogg
QMediaFormat::MPEG4 3 MPEG-4
QMediaFormat::AVI 1 AVI (音頻視頻交錯)
QMediaFormat::QuickTime 5 QuickTime
QMediaFormat::WebM 6 WebM
QMediaFormat::Mpeg4Audio 7 MPEG-4 第 3 部分或 MPEG-4 音頻 (正式 ISO/IEC 14496-3)
QMediaFormat::FLAC 11 FLAC (自由無損音頻編解碼器)
QMediaFormat::UnspecifiedFormat -1 The format is unspecified.

enum QMediaFormat:: ResolveFlags

Describes the requirements for resolving a suitable format for QMediaRecorder .

常量 描述
QMediaFormat::NoFlags 0 No requirements
QMediaFormat::RequiresVideo 1 A video codec is required

另請參閱 resolveForEncoding ().

enum class QMediaFormat:: VideoCodec

Describes the video coded used in multimedia file or stream.

常量 描述
QMediaFormat::VideoCodec::VP8 5 VP8
QMediaFormat::VideoCodec::MPEG2 1 MPEG-2
QMediaFormat::VideoCodec::MPEG1 0 MPEG-1
QMediaFormat::VideoCodec::WMV 9 WMV (Windows 媒體視頻)
QMediaFormat::VideoCodec::H265 4 High Efficiency Video Coding (HEVC)
QMediaFormat::VideoCodec::H264 3 Advanced Video Coding
QMediaFormat::VideoCodec::MPEG4 2 MPEG-4
QMediaFormat::VideoCodec::AV1 7 AOMedia Video 1
QMediaFormat::VideoCodec::MotionJPEG 10 MotionJPEG
QMediaFormat::VideoCodec::VP9 6 VP9
QMediaFormat::VideoCodec::Theora 8 Theora
QMediaFormat::VideoCodec::Unspecified -1 Video codec not specified

特性文檔編製

audioCodec : AudioCodec

This property holds the audio codec of the media.

訪問函數:

QMediaFormat::AudioCodec audioCodec () const
void setAudioCodec (QMediaFormat::AudioCodec codec )

另請參閱 QMediaFormat::AudioCodec .

fileFormat : FileFormat

This property holds the file (container) format of the media.

訪問函數:

QMediaFormat::FileFormat fileFormat () const
void setFileFormat (QMediaFormat::FileFormat f )

另請參閱 QMediaFormat::FileFormat .

videoCodec : VideoCodec

This property holds the video codec of the media.

訪問函數:

QMediaFormat::VideoCodec videoCodec () const
void setVideoCodec (QMediaFormat::VideoCodec codec )

另請參閱 QMediaFormat::VideoCodec .

成員函數文檔編製

QMediaFormat:: QMediaFormat ( QMediaFormat::FileFormat format = UnspecifiedFormat)

構造 QMediaFormat 對象為 format .

[noexcept] QMediaFormat:: QMediaFormat (const QMediaFormat & other )

構造 QMediaFormat 對象通過拷貝自 other .

[noexcept] QMediaFormat:: QMediaFormat ( QMediaFormat && other )

構造 QMediaFormat 對象通過移動自 other .

[noexcept] QMediaFormat:: ~QMediaFormat ()

銷毀 QMediaFormat 對象。

QMediaFormat::AudioCodec QMediaFormat:: audioCodec () const

Returns the audio codec used in this format.

注意: Getter function for property audioCodec.

另請參閱 setAudioCodec () 和 QMediaFormat::AudioCodec .

[static invokable] QString QMediaFormat:: audioCodecDescription ( QMediaFormat::AudioCodec codec )

Returns a description for codec .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[static invokable] QString QMediaFormat:: audioCodecName ( QMediaFormat::AudioCodec codec )

Returns a string based name for codec .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[static invokable] QString QMediaFormat:: fileFormatDescription ( QMediaFormat::FileFormat fileFormat )

Returns a description for fileFormat .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[static invokable] QString QMediaFormat:: fileFormatName ( QMediaFormat::FileFormat fileFormat )

Returns a string based name for fileFormat .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] bool QMediaFormat:: isSupported ( QMediaFormat::ConversionMode mode ) const

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

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

QMimeType QMediaFormat:: mimeType () const

返迴 MIME 類型 for the file format used in this media format.

void QMediaFormat:: resolveForEncoding ( QMediaFormat::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:

  1. 文件格式
  2. 視頻編解碼器
  3. 音頻編解碼器

void QMediaFormat:: setAudioCodec ( QMediaFormat::AudioCodec codec )

將音頻編解碼器設為 codec .

注意: setter 函數對於特性 audioCodec .

另請參閱 audioCodec () 和 QMediaFormat::AudioCodec .

void QMediaFormat:: setVideoCodec ( QMediaFormat::VideoCodec codec )

Sets the video codec to codec .

注意: setter 函數對於特性 videoCodec .

另請參閱 videoCodec () 和 QMediaFormat::VideoCodec .

[invokable] QList < QMediaFormat::AudioCodec > QMediaFormat:: supportedAudioCodecs ( QMediaFormat::ConversionMode m )

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 .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QMediaFormat::ConversionMode .

[invokable] QList < QMediaFormat::FileFormat > QMediaFormat:: supportedFileFormats ( QMediaFormat::ConversionMode m )

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 .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QMediaFormat::ConversionMode .

[invokable] QList < QMediaFormat::VideoCodec > QMediaFormat:: supportedVideoCodecs ( QMediaFormat::ConversionMode m )

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.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

另請參閱 QMediaFormat::ConversionMode .

[noexcept] void QMediaFormat:: swap ( QMediaFormat & other )

Swaps the media format with other .

QMediaFormat::VideoCodec QMediaFormat:: videoCodec () const

Returns the video codec used in this format.

注意: Getter function for property videoCodec.

另請參閱 setVideoCodec () 和 QMediaFormat::VideoCodec .

[static invokable] QString QMediaFormat:: videoCodecDescription ( QMediaFormat::VideoCodec codec )

Returns a description for codec .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[static invokable] QString QMediaFormat:: videoCodecName ( QMediaFormat::VideoCodec codec )

Returns a string based name for codec .

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

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

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

[noexcept] QMediaFormat &QMediaFormat:: operator= ( QMediaFormat && other )

移動 other 到此 QMediaFormat 對象。

[noexcept] QMediaFormat &QMediaFormat:: operator= (const QMediaFormat & other )

拷貝 other 到此 QMediaFormat 對象。

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

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