VideoOutput QML Type

渲染视频或相机取景器。更多

Import Statement: import QtMultimedia
Inherits:

Item

属性

详细说明

Rectangle {
    width: 800
    height: 600
    color: "black"

    MediaPlayer {
        id: player
        source: "file://video.webm"
        videoOutput: videoOutput
    }

    VideoOutput {
        id: videoOutput
        anchors.fill: parent
    }
}

VideoOutput 项支持未变换、拉伸和均匀缩放的视频演示。有关拉伸均匀缩放演示的说明,请参阅fillMode 属性说明。

另请参阅 MediaPlayerCamera

属性文档

contentRect : rectangle

该属性包含要渲染的视频区域的项目坐标。在某些填充模式下,该矩形将大于VideoOutput 的可见区域。

该属性在以源尺寸指定其他坐标时非常有用--适用于 0 至 1.0 范围内的相对(归一化)帧坐标。

超出此范围的区域将是透明的。


fillMode : enumeration

设置此属性可定义如何缩放视频以适应目标区域。

  • Stretch(拉伸)- 视频按比例缩放以适应目标区域。
  • PreserveAspectFit(保留高宽比)- 视频按统一比例缩放以适应目标区域,不进行裁剪
  • PreserveAspectCrop(保留高宽比裁剪)- 统一缩放视频以填充,必要时进行裁剪

默认填充模式为 PreserveAspectFit。


orientation : int

该属性确定显示的视频在视频坐标中顺时针旋转的角度(度),Y 轴在显示屏上指向下方。

方向变化会影响从源到视口的坐标映射。

只支持90 度的倍数,即 0、90、-90、180、270 等,否则指定值将被忽略。

在某些情况下,源视频流需要校正一定的方向。这包括相机取景器等信号源,在这种情况下,无论用户界面的其他部分如何旋转,显示的取景器都应与实际情况相符。

我们建议使用此属性来补偿用户界面的旋转,或使输出视图符合其他应用的业务要求。

默认值为0


sourceRect : rectangle

该属性用于保存渲染时考虑的源视频内容区域。该值以源像素坐标为单位,并根据源像素宽高比进行了调整。

请注意,该矩形的左上角通常是0,0 ,而宽度和高度则是输入内容的宽度和高度。只有当视频源设置了视口时,这些值才会有所不同。

方向设置不会影响该矩形。

另请参阅 QVideoFrameFormat::viewport().


videoSink : object

此属性保存用于将视频帧渲染到此VideoOutput 元素的底层 C++QVideoSink 对象。

正常使用 QML 中的VideoOutput 时不需要使用此属性。


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