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 将自动尝试找到最佳的替代格式并使用它。

另请参阅 MediaRecorderCaptureSession

属性文档

audioCodec : enumeration

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

属性值说明
MediaFormat.WMAWindows 媒体音频
MediaFormat.AC3杜比数字
媒体格式.AAC高级音频编码
媒体格式.ALAC苹果无损音频编解码器
MediaFormat.DolbyTrueHD杜比 TrueHD
MediaFormat.EAC3杜比数字增强(EAC3)
媒体格式.MP3MPEG-1 Audio Layer III 或 MPEG-2 Audio Layer III
媒体格式.Wave波形音频文件格式
媒体格式.VorbisOgg Vorbis
媒体格式.FLAC免费无损音频编解码器
媒体格式.OpusOpus 音频格式
MediaFormat.Unspecified未指定编解码器

fileFormat : enumeration

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

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

videoCodec : enumeration

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

属性值说明
MediaFormat.VP8VP8
MediaFormat.MPEG2MPEG-2
MediaFormat.MPEG1MPEG-1
媒体格式.WMVWindows 媒体视频
媒体格式.H265高效视频编码(HEVC)
媒体格式.H264高级视频编码
媒体格式.MPEG4MPEG-4
媒体格式 AV1AOMedia视频1
媒体格式.MotionJPEGMotionJPEG
媒体格式.VP9VP9
MediaFormat.TheoraTheora
媒体格式.未指定未指定视频编解码器

方法文档

string audioCodecDescription(codec)

返回codec 的描述。


string audioCodecName(codec)

codec 返回基于字符串的名称。


string fileFormatDescription(fileFormat)

返回fileFormat 的描述。


string fileFormatName(fileFormat)

返回fileFormat 的字符串名称。


list<AudioCodec> supportedAudioFormats(conversionMode)

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

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

另请参阅 QMediaFormat::ConversionMode


list<FileFormat> supportedFileFormats(conversionMode)

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

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

另请参阅 QMediaFormat::ConversionMode


list<VideoCodec> supportedVideoCodecs(conversionMode)

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

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

另请参阅 QMediaFormat::ConversionMode


string videoCodecDescription(codec)

返回codec 的描述。


string videoCodecName(codec)

codec 返回基于字符串的名称。


© 2025 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.