本页内容

mediaFormat QML Value Type

MediaFormat 描述了媒体文件的格式。更多内容...

Import Statement: import QtMultimedia

属性

方法

详细说明

MediaFormat 类型用于描述媒体文件的格式。它包含三个属性,用于描述文件类型以及所使用的音频和视频编解码器。

MediaFormat 可用于指定MediaRecorder 应创建的文件类型。下面的代码片段展示了一个示例,该示例将录像机配置为创建带有 AAC 编码音频和 H265 视频的 mpeg4 视频:

CaptureSession {
    ... // setup inputs
    MediaRecorder {
        mediaFormat {
            fileFormat: MediaFormat.MPEG4
            audioCodec: MediaFormat.AudioCodec.AAC
            videoCodec: MediaFormat.VideoCodec.H265
        }
    }
}

如果指定的 mediaFormat 不受支持,MediaRecorder 将自动尝试查找最佳的替代格式并使用该格式。

另请参阅 MediaRecorder 和CaptureSession 。

属性文档

audioCodec : enumeration

描述多媒体文件或流中使用的音频编解码器。该属性可取以下值之一:

属性值描述
MediaFormat.WMAWindows Media Audio
MediaFormat.AC3杜比数字
MediaFormat.AAC高级音频编码
MediaFormat.ALACApple 无损音频编解码器
MediaFormat.DolbyTrueHD杜比TrueHD
MediaFormat.EAC3杜比数字增强版 (EAC3)
MediaFormat.MP3MPEG-1 音频层 III 或 MPEG-2 音频层 III
MediaFormat.Wave波形音频文件格式
MediaFormat.VorbisOgg Vorbis
MediaFormat.FLAC免费无损音频编解码器
MediaFormat.OpusOpus 音频格式
MediaFormat.Unspecified未指定的编解码器

fileFormat : enumeration

描述多媒体文件或流中使用的容器格式。该属性可取以下值之一:

属性值描述
MediaFormat.WMAWindows Media Audio
MediaFormat.AAC高级音频编码
MediaFormat.MatroskaMatroska (MKV)
MediaFormat.WMVWindows Media Video
MediaFormat.MP3MPEG-1 音频层 III 或 MPEG-2 音频层 III
MediaFormat.Wave波形音频文件格式
MediaFormat.OggOgg
MediaFormat.MPEG4MPEG-4
MediaFormat.AVI音频视频交错格式
MediaFormat.QuickTimeQuickTime
MediaFormat.WebMWebM
MediaFormat.Mpeg4AudioMPEG-4 第3部分或 MPEG-4 音频(正式名称为 ISO/IEC 14496-3)
MediaFormat.FLAC免费无损音频编解码器
MediaFormat.UnspecifiedFormat该格式未指定。

videoCodec : enumeration

描述多媒体文件或流中使用的视频编解码器。该属性可取以下值之一:

属性值描述
MediaFormat.VP8VP8
MediaFormat.MPEG2MPEG-2
MediaFormat.MPEG1MPEG-1
MediaFormat.WMVWindows Media Video
MediaFormat.H265高效视频编码 (HEVC)
MediaFormat.H264高级视频编码
MediaFormat.MPEG4MPEG-4
MediaFormat.AV1AOMedia 视频 1
MediaFormat.MotionJPEGMotionJPEG
MediaFormat.VP9VP9
MediaFormat.TheoraTheora
MediaFormat.Unspecified未指定视频编解码器

方法文档

string audioCodecDescription(codec)

返回codec 的描述。

string audioCodecName(codec)

返回codec 的字符串名称。

string fileFormatDescription(fileFormat)

返回fileFormat 的描述。

string fileFormatName(fileFormat)

返回fileFormat 的字符串名称。

list<AudioCodec> supportedAudioFormats(conversionMode)

返回所选文件格式和视频编解码器(conversionMode )对应的音频编解码器列表。

要获取所有受支持的音频编解码器,请在默认构造的 MediaFormat 上运行此查询。要获取特定文件格式与视频编解码器组合所支持的音频编解码器列表,可以在运行此查询之前设置fileFormat 和videoCodec 属性。

另请参阅 QMediaFormat::ConversionMode 。

list<FileFormat> supportedFileFormats(conversionMode)

返回由conversionMode 指定的音频和视频编解码器所支持的文件格式列表。

要获取所有受支持的文件格式,请在默认构造的 MediaFormat 上运行此查询。要获取支持特定音频和视频编解码器组合的文件格式列表,可以在运行此查询之前设置audioCodec 和videoCodec 属性。

另请参阅 QMediaFormat::ConversionMode 。

list<VideoCodec> supportedVideoCodecs(conversionMode)

返回所选文件格式和音频编解码器(conversionMode )对应的视频编解码器列表。

要获取所有受支持的视频编解码器,请在默认构造的 MediaFormat 上运行此查询。要获取特定文件格式和音频编解码器组合所支持的视频编解码器列表,可以在运行此查询之前设置fileFormat 和audioCodec 属性。

另请参阅 QMediaFormat::ConversionMode 。

string videoCodecDescription(codec)

返回codec 的描述。

string videoCodecName(codec)

返回codec 的字符串形式的名称。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.