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-ffmpeg-stubs.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qtmultimedia-ffmpeg-stubs.html
6
\title FFmpeg stub libraries on Linux and Android
7
\brief This document explains the stub mechanism used for FFmpeg's dynamic dependencies on Linux
8
and Android platforms.
9
10
\section1 Overview
11
12
To support dynamic linking of \l{FFmpeg} in compliance with the LGPL license, Qt Multimedia uses
13
\b{stub libraries} to handle optional external dependencies on Linux and Android platforms.
14
15
On these platforms, FFmpeg may require additional shared libraries that are not shipped with Qt:
16
17
\list
18
\li \b{OpenSSL} - required for secure network streaming.
19
\li \b{VAAPI} (Linux only) - enables hardware-accelerated video decoding and encoding.
20
\endlist
21
22
These libraries are often not available or cannot be bundled due to licensing constraints. To ensure
23
FFmpeg-based features remain functional (excluding the unsupported parts), Qt delivers
24
\e{stub libraries} as fallbacks.
25
26
\section1 Why Stubs Are Needed
27
28
If these dependencies are not present at runtime, FFmpeg will fail to load or function properly.
29
The stub mechanism allows:
30
31
\list
32
\li Successful loading of FFmpeg even when OpenSSL or VAAPI are missing.
33
\li Graceful degradation of functionality (e.g., lack of VAAPI results in no hardware
34
acceleration, but playback still works).
35
\li Users to \b{opt-in} to using their own system-provided versions of these libraries if available.
36
\endlist
37
38
\section1 What Stubs Are
39
40
Stub libraries mimic the interfaces of the real libraries (e.g., \c{libssl.so}, \c{libva.so}) but
41
do not implement full functionality. Instead, they:
42
43
\list
44
\li Provide dummy implementations that return safe fallback values or no-ops.
45
\li Dynamically attempt to resolve real symbols via \c{QLibrary::load} / \c{QLibrary::resolve}.
46
\li Fail gracefully if real libraries are not found.
47
\endlist
48
49
Qt ships these stubs under the names:
50
51
\list
52
\li \c{libQt6FFmpegStub-ssl.so.x}
53
\li \c{libQt6FFmpegStub-crypto.so.x}
54
\li \c{libQt6FFmpegStub-va.so.x}
55
\li \c{libQt6FFmpegStub-va-drm.so.x}
56
\li \c{libQt6FFmpegStub-va-x11.so.x}
57
\li (more may be added in the future)
58
\endlist
59
60
\section1 How Stubs Work in Qt
61
62
When FFmpeg is dynamically linked:
63
64
\list
65
\li It normally expects to be linked against system libraries like \c{libssl.so.3} or \c{libva.so.2}.
66
\li Qt patches the FFmpeg binaries using the \c{patchelf} tool to replace these real
67
dependencies with stub equivalents.
68
\endlist
69
70
Example:
71
72
\badcode
73
# Original linkage
74
libffmpegmediaplugin.so: needs libavcodec.so (depends on the FFmpeg libs)
75
libavcodec.so: needs libssl.so.3
76
77
# After patching
78
libffmpegmediaplugin.so: needs libavcodec.so (no changes)
79
libavcodec.so: needs libQt6FFmpegStub-ssl.so.3
80
libQt6FFmpegStub-ssl.so.3: optionally needs libssl.so.3 (no explicit linkage)
81
\endcode
82
83
This patching is performed automatically as part of the build/distribution process.
84
85
\section1 Runtime Behavior and Security Notes
86
87
\list
88
\li FFmpeg plugins are loaded with \c{dlopen(..., RTLD_LOCAL)}, so stub symbols do not leak into
89
the global symbol table.
90
\li If the application already uses OpenSSL or VAAPI, the system libraries may be picked up from
91
the global scope and must be binary compatible.
92
\li The shipped QtMultimedia and FFmpeg binaries are compatible with:
93
\list
94
\li \b{OpenSSL 3.x.x} (with symbol versioning \c{@OPENSSL_3.0.0})
95
\li \b{VAAPI ABI 0.33} (older ABI 0.32 is explicitly unsupported)
96
\endlist
97
\li It is also possible to build Qt Multimedia against \b{OpenSSL 1.x.x}, though compatibility
98
depends on your FFmpeg configuration.
99
\endlist
100
101
To completely remove the use of stub libraries, there are two options:
102
103
\list
104
\li Use \c{patchelf} to restore FFmpeg's dependencies back to the system libraries (e.g., replace
105
\c{libQt6FFmpegStub-ssl.so.3} with \c{libssl.so.3}). This must be done for all FFmpeg libraries:
106
\c{libavcodec}, \c{libavformat}, \c{libavutil}, \c{libswresample}, and \c{libswscale}.
107
\li Replace the shipped FFmpeg libraries with ones built manually by the user.
108
See \l{Building FFmpeg from source}.
109
\endlist
110
111
*/
qtmultimedia
src
multimedia
doc
src
qtmultimedia-ffmpeg-stubs.qdoc
Generated on
for Qt by
1.14.0