Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtmultimedia-index.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 \page qtmultimedia-index.html
6 \title Qt Multimedia
7 \image noun_Media_166644.svg "image of multimedia icons, courtesy of misirlou from the Noun Project"
8 \brief The Qt Multimedia module provides APIs for playing back and recording
9 audiovisual content
10
11 Qt Multimedia is an add-on module that provides a rich set of QML types
12 and C++ classes to handle multimedia content. It contains an easy to use
13 API for playing back audio and video files and rendering those on screen,
14 as well as a comprehensive API for recording audio and video from various
15 sources, including system cameras and microphones, screen or window
16 captures, and audio or video memory buffers.
17
18 The functionality of this module is divided into the following submodules:
19
20 \table
21 \row
22 \li \l{Multimedia Overview}{Qt Multimedia}
23 \li Provides an API for multimedia-specific use cases.
24 \row
25 \li \l{Qt Multimedia Widgets}
26 \li Provides a widget-based multimedia API.
27 \row
28 \li \l{Qt Spatial Audio}
29 \li Provides an API for implementing sound fields in 3D space.
30 \endtable
31
32 \section1 Getting started
33 If you are porting from Qt 5 to Qt 6, see \l{Changes to Qt Multimedia}.
34
35 \include cmake-find-package-multimedia.qdocinc {qml-import-intro} {Qt Multimedia} {import QtMultimedia}
36
37 To link against the C++ libraries, add the following to your project's
38 \c CMakeLists.txt file. Substitute \c mytarget with the name of your
39 project.
40
41 \include cmake-find-package-multimedia.qdocinc {find-and-link} {Multimedia} {PRIVATE} {Qt6::Multimedia}
42
43 See \l {Building Qt Multimedia from sources} for guidance on building
44 Qt Multimedia from sources.
45
46 \section1 Overviews and important topics
47
48 \list
49 \li \l{Changes to Qt Multimedia}{Changes in Qt 6}
50 \li \l{Multimedia Overview}
51 \li \l{Audio Overview}
52 \li \l{Spatial Audio Overview}
53 \li \l{Video Overview}
54 \li \l{Camera Overview}
55 \li \l{Supported Media Formats}
56 \endlist
57
58 \section1 QML types
59
60 The following table outlines some important QML types.
61
62 \table
63 \header
64 \li Type
65 \li Description
66 \row
67 \li \l{MediaPlayer}
68 \li Add audio/video playback functionality to a scene.
69 \row
70 \li \l {QtMultimedia::CaptureSession}{CaptureSession}
71 \li Create a session for capturing audio/video.
72 \row
73 \li \l {QtMultimedia::Camera}{Camera}
74 \li Access a camera connected to the system.
75 \row
76 \li \l {QtMultimedia::AudioInput}{AudioInput}
77 \li Access an audio input (microphone) connected to the system.
78 \row
79 \li \l {QtMultimedia::AudioOutput}{AudioOutput}
80 \li Access an audio output (speaker, headphone) connected to the system.
81 \row
82 \li \l {QtMultimedia::VideoOutput}{VideoOutput}
83 \li Display video content.
84 \row
85 \li \l {QtMultimedia::MediaRecorder}{MediaRecorder}
86 \li Record audio/video from the CaptureSession.
87 \row
88 \li \l {QtMultimedia::ImageCapture}{ImageCapture}
89 \li Capture still images from the Camera.
90 \row
91 \li \l {QtMultimedia::Video}{Video}
92 \li Add Video playback functionality to a scene. Uses MediaPlayer and
93 VideoOutput types to provide video playback functionality.
94 \row
95 \li \l {QtMultimedia::ScreenCapture}{ScreenCapture}
96 \li Captures a screen.
97 \row
98 \li \l {QtMultimedia::WindowCapture}{WindowCapture}
99 \li Captures a top-level window.
100 \row
101 \li \l {QtMultimedia::GStreamerVideoSource}{GStreamerVideoSource}
102 \li Custom GStreamer video source (with the GStreamer media backend).
103 \endtable
104
105 \section1 C++ classes
106
107 The following table outlines some important C++ classes.
108
109 \table
110 \header
111 \li Class
112 \li Description
113 \row
114 \li QMediaPlayer
115 \li Playback media from a source.
116 \row
117 \li QVideoWidget
118 \li Display video from a media player or a capture session.
119 \row
120 \li QMediaCaptureSession
121 \li Capture audio and video.
122 \row
123 \li QCamera
124 \li Access a camera connected to the system
125 \row
126 \li QAudioInput
127 \li Access an audio input (microphone) connected to the system.
128 \row
129 \li QAudioOutput
130 \li Access an audio output (speaker, headphone) connected to the system.
131 \row
132 \li QImageCapture
133 \li Capture still images with a camera.
134 \row
135 \li QMediaRecorder
136 \li Record media content from a capture session.
137 \row
138 \li QVideoSink
139 \li Access and render individual video frames.
140 \row
141 \li QAudioSink
142 \li Sends raw audio data to an audio output device.
143 \row
144 \li QScreenCapture
145 \li Captures a screen.
146 \row
147 \li QWindowCapture
148 \li Captures a top-level window.
149 \row
150 \li QVideoFrameInput
151 \li Used to display or record video frames from memory buffers.
152 \row
153 \li QAudioBufferInput
154 \li Supports playing or recording audio from memory buffers.
155 \row
156 \li QGStreamerVideoSource
157 \li Custom GStreamer video source (with the GStreamer media backend).
158
159 \endtable
160
161 For playback of audio and video, QMediaPlayer, QAudioOutput, and
162 QVideoWidget contain all necessary functionality. Other classes are
163 dedicated to capturing audio and video content, with
164 QMediaCaptureSession serving as the central class that manages the
165 entire capture and recording process.
166
167 \section1 Licenses and attributions
168
169 The Qt Multimedia module is available under commercial licenses from
170 \l{The Qt Company}.
171 In addition, it is available under free software licenses. Since Qt 5.6,
172 these free software licenses are
173 \l{GNU Lesser General Public License, version 3}, or
174 the \l{GNU General Public License, version 2}.
175 See \l{Qt Licensing} for further details.
176
177 Furthermore, Qt Multimedia in Qt \QtVersion may contain third-party modules
178 under the following permissive licenses:
179
180 \annotatedlist attributions-qtmultimedia
181
182 Note that video compression standards, such as the H.264 media compression
183 standard, may be covered by patents and can incur royalty fees. This can
184 apply to any implementation, also if the implementation is provided as an
185 operating system service, through a third-party library, or any of
186 Qt Multimedia's backends. The Qt licenses do not cover such fees.
187
188 \section1 Target platform and backend notes
189 Qt Multimedia offers user-friendly, cross-platform APIs for media
190 playback, recording, and device management. The implementation of
191 core APIs, including QMediaDevices, QAudioDevice, QSoundEffect,
192 QAudioSink, and QAudioSource are integrated into the main Qt
193 Multimedia library, eliminating the need for additional libraries.
194 Other Qt Multimedia APIs are implemented using plugin libraries
195 known as media backends. The main media backend, built on \l
196 {http://ffmpeg.org}{FFmpeg}, ensures seamless cross-platform
197 functionality, and is the default on all platforms except
198 WebAssembly and embedded Linux/Boot2Qt. With Boot2Qt, the default
199 backend is built on top of \l
200 {https://gstreamer.freedesktop.org/}{GStreamer}, but the FFmpeg
201 media backend can be enabled using the \c{QT_MEDIA_BACKEND}
202 environment variable.
203
204 \section2 The FFmpeg backend
205
206 The FFmpeg media backend relies on the \b{FFmpeg \ffmpegversion} libraries,
207 which are included with the Qt Online Installer and tested by the
208 maintainers. The binary packages from the online installer use
209 dynamic linking to FFmpeg. Therefore, applications must either
210 bundle FFmpeg binaries in their installer or depend on FFmpeg being
211 installed on the operating system. The FFmpeg libraries are
212 automatically deployed using Qt's deployment tools as described in
213 the \l{Deploying Qt Applications} documentation, except for \l{Qt
214 for Linux/X11 - Deployment}{Linux/X11}. Applications can also deploy
215 their own build of FFmpeg, either as shared or static libraries,
216 provided the FFmpeg major version matches the version used by Qt.
217
218 While Qt Multimedia leverages the FFmpeg media backend on most
219 operating systems, platform specific functional or visual
220 differences may arise between applications on different platforms.
221 FFmpeg does not provide identical codec and format support across
222 all platforms, and the performance of Qt Multimedia features may
223 depend on hardware support that is only available on certain
224 platforms. For instance, FFmpeg encounters specific issues with
225 hardware acceleration on Linux targets with ARM architectures.
226 Therefore, it is recommended to test Qt Multimedia applications on
227 all target platforms.
228
229 \note The FFmpeg project provides features under various licenses.
230 The pre-built FFmpeg libraries that are provided through the Online
231 Installer are only including features that agree with the permissive
232 licenses listed under \l{Licenses and Attributions}.
233
234 To ease development and debugging, some FFmpeg functionality is
235 configurable via \l {advanced-ffmpeg-configuration}{environment
236 varibles} which are part of the private Qt Multimedia API.
237
238 \section2 Native backends
239
240 For compatibility with existing applications, we maintain native
241 media backends for each operating system:
242
243 \list
244 \li \l{Qt Multimedia GStreamer Backend}{GStreamer backend} on Embedded Linux
245 \li AVFoundation on macOS and iOS
246 \li Windows Media Foundation on Windows (deprecated since Qt 6.10)
247 \li MediaCodec framework on Android
248 \li WebAudio and WebVideo on WebAssembly
249 \endlist
250
251 \note The FFmpeg media backend is the default backend except on WebAssembly,
252 native backends are still available but with \b limited support. The
253 GStreamer backend is only available on Linux, and is only
254 recommended for embedded applications.
255 \note MediaCodec on Android is deprecated as of Qt 6.8 and will be
256 removed in the next major release.
257 \note The Windows media backend built on top of Windows Media
258 Foundation is deprecated as of Qt 6.10 and will be removed in the
259 next major release.
260
261 Qt Maintainers will strive to fix critical issues with the native
262 backends but don't guarantee fixing minor issues, including
263 inconsistent behavior across platforms. New features will only be
264 implemented on the FFmpeg media backend, with the exception of WebAssembly.
265
266 The GStreamer backend has some private APIs to allow more fine-grained control.
267 However, there are known bugs in the GStreamer backend. More details can be found
268 in \l{Qt Multimedia GStreamer Backend}{platform notes for the GStreamer backend}.
269
270 Backend limitations will be documented, and their status will be maintained in the
271 respective classes.
272
273 \section2 Changing backends
274
275 In the case of issues with the default FFmpeg backend, we suggest testing with a native backend.
276 You can switch to native backends by setting the \c{QT_MEDIA_BACKEND} environment variable
277 to \c windows, \c gstreamer (on Embedded Linux), \c darwin (on macOS and iOS), or \c android:
278
279 \code
280 export QT_MEDIA_BACKEND=darwin
281 \endcode
282
283 To force assign FFmpeg as the used backend, set the variable to \c ffmpeg:
284
285 \code
286 export QT_MEDIA_BACKEND=ffmpeg
287 \endcode
288
289 On the Qt Multimedia compilation stage, the default media backend can be configured
290 via cmake variable \c{QT_DEFAULT_MEDIA_BACKEND}.
291
292 \section2 Target platform notes
293 The following pages list issues for specific target platforms.
294
295 \list
296 \li \l{Qt Multimedia on macOS and iOS}{macOS and iOS}
297 \li \l{Qt Multimedia on WebAssembly}{WebAssembly}
298 \li \l{Qt Multimedia on Windows}{Windows}
299 \li \l{Qt Multimedia on Linux}{Linux}
300 \li \l{Qt Multimedia GStreamer Backend}{GStreamer backend for embedded Linux}
301 \endlist
302
303 \section1 Permissions
304
305 Starting from Qt 6.6, the Qt Multimedia module uses the new \l QPermission API
306 to handle \l {QCameraPermission}{camera} and
307 \l {QMicrophonePermission}{microphone} permissions. This means that Qt
308 itself no longer queries for these permissions, so this needs to be done
309 directly from the client application.
310
311 Please refer to the \l {Application Permissions} page for an example of how
312 to integrate the new \l QPermission API into the application.
313
314 \section1 Reference and examples
315 \list
316 \li \l{Qt Multimedia QML Types}{QML Types}
317 \li \l{Qt Multimedia C++ Classes}{C++ Classes}
318 \li \l{Qt Multimedia Examples}{Examples}
319 \endlist
320*/