VideoOutput QML Type

Render video or camera viewfinder. More...

Import Statement: import QtMultimedia

Properties

Methods

Detailed Description

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

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

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

The VideoOutput item supports untransformed, stretched, and uniformly scaled video presentation. For a description of stretched uniformly scaled presentation, see the fillMode property description.

See also MediaPlayer and Camera.

Property Documentation

contentRect : rectangle

This property holds the item coordinates of the area that would contain video to render. With certain fill modes, this rectangle will be larger than the visible area of the VideoOutput.

This property is useful when other coordinates are specified in terms of the source dimensions - this applied for relative (normalized) frame coordinates in the range of 0 to 1.0.

Areas outside this will be transparent.


endOfStreamPolicy : enumeration [since 6.9]

This property specifies the policy to apply when the video stream ends. This occurs at the end of media playback or upon deactivation of the camera, screen, or window capture.

The endOfStreamPolicy can be one of:

ConstantDescription
ClearOutputThe video output is cleared.
KeepLastFrameThe video output continues displaying the last frame. Use the method clearOutput() to clear the output manually.

The default value is ClearOutput.

This property was introduced in Qt 6.9.


fillMode : enumeration

Set this property to define how the video is scaled to fit the target area.

  • Stretch - the video is scaled to fit.
  • PreserveAspectFit - the video is scaled uniformly to fit without cropping
  • PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary

The default fill mode is PreserveAspectFit.


mirrored : bool [since 6.9]

Determines whether the displayed video is mirrored around its vertical axis. We recommend using this property if the transformation of the source video stream, such as from a front camera, does not align with the application's business logic. The mirroring is applied after orientation.

The property change affects the mapping of coordinates from the source to the viewport.

The default value is false.

This property was introduced in Qt 6.9.


orientation : int

This property determines the angle in, degrees, at which the displayed video is rotated clockwise in video coordinates, where the Y-axis points downwards on the display. The orientation transformation is applied before mirorred.

The orientation change affects the mapping of coordinates from the source to the viewport.

Only multiples of 90 degrees are supported, that is 0, 90, -90, 180, 270, etc., otherwise, the specified value is ignored.

In some cases, the source video stream requires a certain orientation to be corrected. This includes sources like a camera viewfinder, where the displayed viewfinder should match the reality, no matter what rotation the rest of the user interface has.

We recommend using this property to compensate a user interface rotation, or align the output view with other application business requirements.

The default value is 0.


sourceRect : rectangle

This property holds the area of the source video content that is considered for rendering. The values are in source pixel coordinates, adjusted for the source's pixel aspect ratio.

Note that typically the top left corner of this rectangle will be 0,0 while the width and height will be the width and height of the input content. Only when the video source has a viewport set, these values will differ.

The orientation setting does not affect this rectangle.

See also QVideoFrameFormat::viewport().


videoSink : object

This property holds the underlaying C++ QVideoSink object that is used to render the video frames to this VideoOutput element.

Normal usage of VideoOutput from QML should not require using this property.


Method Documentation

[since 6.9] void clearOutput()

Clears the video output by removing the currently displayed video frame. This method is recommended when you need to remove the last video frame after detaching the video output from the source or after the source stream ends with the video output's endOfStreamPolicy property set to KeepLastFrame.

This method was introduced in Qt 6.9.


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