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
advanced-ffmpeg-configuration.qdoc
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page advanced-ffmpeg-configuration.html
6\title Advanced FFmpeg Configuration
7\brief Lists the FFmpeg media backend's configurable features.
8\ingroup explanations-graphicsandmultimedia
9
10This page lists the FFmpeg media backend's configurable features. All the features are a part of
11the private API and can be changed or removed in the future without confirmation. Be aware
12that environment variables are by default inherited by child processes and can have unintended
13consequences.
14
15\section1 Enable logging from FFmpeg and the Qt FFmpeg media backend
16
17You can configure advanced FFmpeg log output via environment variables.
18
19\list
20 \li \c QT_FFMPEG_DEBUG=1 enables extra logging from the FFmpeg library and can help
21 you understand issues that involve the FFmpeg library.
22
23 \li \c QT_LOGGING_RULES="*.ffmpeg.*=true" turns on Qt developer logs in the FFmpeg plugin.
24 Logging categories in the FFmpeg plugin are usually called "qt.multimedia.ffmpeg.XXX".
25 To enable developer logs from all of Qt Multimedia, set
26 \c QT_LOGGING_RULES="*.multimedia.*=true"
27
28 \li If you set both \c QT_FFMPEG_DEBUG and \c QT_LOGGING_RULES, all available FFmpeg codecs
29 will be printed the first time encoding or decoding functionality is used from
30 \l QMediaPlayer, \l QAudioDecoder, or \l QMediaRecorder. This information
31 can help you understand situations where Qt Multimedia doesn't find a proper FFmpeg
32 decoder or encoder. We recommend attaching the codec dump to Qt bug reports if you
33 encounter codec-specific issues.
34\endlist
35
36\section1 Enable experimental FFmpeg codecs
37
38FFmpeg exposes a few codecs, such as Opus or Vorbis, as experimental ones. Experimental
39codecs don't strictly follow the standard and may be unstable. They are disabled by default.
40To enable them, set the environment variable \c QT_ENABLE_EXPERIMENTAL_CODECS=1.
41
42\section1 Configuring allowed network protocols
43
44For security reasons, the FFmpeg library restricts use of nested protocols, meaning protocols
45used by other protocols; see
46\l {https://www.ffmpeg.org/ffmpeg-protocols.html}{FFmpeg protocols documentation}.
47You may explicitly override the allowed protocols via the environment variable
48\c QT_FFMPEG_PROTOCOL_WHITELIST, for example:
49
50\code
51 export QT_FFMPEG_PROTOCOL_WHITELIST=file,crypto,rtp,udp
52\endcode
53
54\warning Note that nested protocols can introduce security vulnerabilities when used with
55 untrusted data. Only allow protocols that align with your security and business
56 requirements.
57
58\section1 Configuring RTSP transport
59
60RTSP input streams can be opened with a specific FFmpeg RTSP lower transport by setting
61the \c QT_FFMPEG_RTSP_TRANSPORT environment variable. The value is passed to FFmpeg's
62\c rtsp_transport input option for \c rtsp:// URLs. For example, use TCP interleaving
63within the RTSP control channel:
64
65\code
66 export QT_FFMPEG_RTSP_TRANSPORT=tcp
67\endcode
68
69Common values include \c udp, \c tcp, \c udp_multicast, \c http, and \c https; see
70\l {https://www.ffmpeg.org/ffmpeg-protocols.html#rtsp}{FFmpeg's RTSP protocol documentation}.
71This option is not set by default and is ignored for non-RTSP media sources.
72
73\section1 Configure hardware acceleration in backends
74
75\list
76 \li Explicit decoding and encoding hardware acceleration backends.
77
78 The FFmpeg plugin chooses the hardware acceleration backend for decoding and encoding
79 based on availability, stability, efficiency, and implementation details. If the selected
80 hardware backend doesn't work as expected, you can try setting a custom priority list or
81 disable all the hardware backends via the environment variables
82 \c QT_FFMPEG_DECODING_HW_DEVICE_TYPES and \c QT_FFMPEG_ENCODING_HW_DEVICE_TYPES.
83 The available hardware backends include:
84
85 \list
86 \li cuda
87 \li drm
88 \li dxva2
89 \li d3d11va
90 \li d3d12va,
91 \li opencl
92 \li qsv
93 \li vaapi
94 \li vdpau
95 \li videotoolbox
96 \li mediacodec
97 \li vulkan
98 \endlist
99
100 However, the availability of hardware backends depends on the OS, installed drivers,
101 the FFmpeg version, and configuration. It's important to keep in mind that some device
102 types have not been tested with Qt Multimedia by the Qt maintainers, and may not
103 operate as intended. At the time of writing, these backends include:
104
105 \list
106 \li drm
107 \li opencl
108 \li qsv
109 \li vdpau
110 \li vulkan
111 \endlist
112
113 Examples:
114
115 \code
116 # Set vdpau or cuda encoding hardware backends
117 export QT_FFMPEG_ENCODING_HW_DEVICE_TYPES=vdpau,cuda
118
119 # Set only d3d12va decoding hardware backend
120 export QT_FFMPEG_DECODING_HW_DEVICE_TYPES=d3d12va
121
122 # Disable decoding hw backends (set an empty list)
123 export QT_FFMPEG_DECODING_HW_DEVICE_TYPES=,
124 \endcode
125
126 \li Hardware textures conversion.
127
128 Utilizing GPU-based conversion for decoded and rendered video frames can significantly
129 reduce CPU usage. We aim to make use of this reature feature with as many hardware backends
130 as possible. If you notice any rendering issues, consider testing the rendering without GPU
131 texture conversion to identify the cause. You can disable GPU texture conversion by using
132 the \c QT_DISABLE_HW_TEXTURES_CONVERSION environment variable:
133 \c QT_DISABLE_HW_TEXTURES_CONVERSION=1. With the \c VAAPI hardware backend, hardware
134 texture conversion is disabled by default. Set \c QT_XCB_GL_INTEGRATION=xcb_egl to
135 enable it.
136
137 \li Allow codec profile mismatch.
138
139 If the codec profile does not match the reported capabilities of the hardware, you may
140 ignore the mismatch and allow hardware decoding via
141 \c QT_FFMPEG_HW_ALLOW_PROFILE_MISMATCH=1. Setting this option may be helpful, for example,
142 when you use the hardware accelerated decoding for baseline profile H.264 with
143 the \c VAAPI hardware backend because most of such streams satisfy the constraints
144 of the existing H.264 hardware decoder.
145
146 \warning If the stream is not supported, the enforced hardware decoding can cause entirely
147 incorrect video output.
148
149\endlist
150*/