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