Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
videooverview.qdoc
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5
6\page videooverview.html
7\title Video Overview
8\brief Video playback
9
10\section1 Video Features
11
12Qt Multimedia offers both high and low level C++ classes for playing and
13manipulating video data, and QML types for playback and recording. Some
14of the classes presented here overlap with what is presented in the \l {Camera Overview} and
15\l {Audio Overview}.
16
17\section1 Video Implementation Details
18
19\target multimedia-playing-video
20\section2 Playing Video in C++
21
22You can use the \l QMediaPlayer class to decode a video file, and display
23it using \l QVideoWidget, \l QGraphicsVideoItem, or a custom class.
24
25Here's an example of using QVideoWidget:
26 \snippet multimedia-snippets/video.cpp Video widget
27
28And an example with QGraphicsVideoItem:
29 \snippet multimedia-snippets/video.cpp Video graphics item
30
31\section2 Playing Video in QML
32
33You can use \l VideoOutput to render content that is provided by
34either a \l MediaPlayer or a \l Camera. The VideoOutput is a visual
35component that can be embedded into a QQuickScene or \l Window, while
36all media decoding and playback control is handled by the \l MediaPlayer
37or \l CaptureSession. A \l Video element has been provided for convenience.
38It combines MediaPlayer, VideoOutput and AudioOutput elements in one item.
39
40\section2 Working with Low Level Video Frames
41
42Qt Multimedia offers a number of low level classes to make handling
43video frames a bit easier. These classes are primarily used when
44writing code that processes video or camera frames (for example,
45detecting barcodes, or applying a fancy vignette effect), or needs
46to display video in a special way that is otherwise unsupported.
47
48The \l QVideoFrame class encapsulates a video frame and allows the
49contents to be mapped into system memory for manipulation or
50processing. Using your own QVideoSink
51allows you to receive these frames from \l QMediaPlayer and
52\l QCamera.
53
54\section2 Recording Video
55The central class for any type of capturing or recording of audio and video is QMediaCaptureSession
56(or the CaptureSession QML type). You can connect a QCamera (Camera in QML) and a QMediaRecorder
57(MediaRecorder)to the session and then ask the media recorder to start recording.
58
59\section1 Supported Media Formats
60
61What media formats are supported ultimately depends on the configuration of the
62target system.
63
64\section2 Windows
65By default what is available on a MS Windows target depends on the version of
66\l{Windows Media Player} that was packaged with the OS. See the
67\l{Windows Media Player documentation} for official information.
68
69Independent of Windows Media Player, there are of course numerous codec packs
70that could be installed. See the \l{codec guide} site for some examples.
71
72\section2 Android
73See \l{Android supported media formats} for this information.
74
75\section2 Linux
76On Linux this is about installing the correct \l{GStreamer} plugins.
77
78\section3 Minimum Required GStreamer Plugins
79\list
80\li gstreamer1.0-plugins-base
81\li gstreamer1.0-plugins-good
82\li gstreamer1.0-plugins-pulseaudio
83\endlist
84
85For a Linux desktop target, it is strongly recommended to have \c gstreamer1.0-libav
86for good codec coverage and \c gstreamer1.0-vaapi to get hardware acceleration.
87
88On embedded Linux, the required set of plugins could be somewhat different.
89
90\section2 Determining Supported Media Formats at Runtime
91You can determine what formats are available on a target system at runtime using
92the static QMediaFormat API.
93
94\list
95\li Use \l QMediaFormat::isSupported() on a QMediaFormat::ConversionMode to query a
96 specific format.
97\li Use \l QMediaFormat::supportedFileFormats() on a default constructed QMediaFormat
98 to get all the supported file formats.
99\endlist
100
101\section1 Examples
102
103There are both C++ and QML examples available.
104
105\section2 C++ Examples
106
107\annotatedlist video_examples
108
109\section2 QML Examples
110
111\annotatedlist video_examples_qml
112
113\section1 Reference Documentation
114
115\section2 C++ Classes
116
117\annotatedlist multimedia_video
118
119\section2 QML Types
120
121\annotatedlist multimedia_video_qml
122
123*/