Skip to content

Commit efcb24a

Browse files
committed
deploy: a574980
1 parent 86e783c commit efcb24a

254 files changed

Lines changed: 1071 additions & 1071 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/common/6/hw-encoding.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ <h2>API Reference</h2>
141141
<div class="textblock"><p>When recording video using the <code><a class="el" href="classgz_1_1common_1_1VideoEncoder.html" title="The VideoEncoder class supports encoding a series of images to a video format, and then writing the v...">gz::common::VideoEncoder</a></code> class, you can opt-in to use hardware (HW) acceleration for the encoding process. By default, only software encoders are used. This tutorial will show how to configure the encoder for HW acceleration and will present ready-made commandlines for some typical use-cases.</p>
142142
<p>You can either use the <code>VideoEncoder</code> class directly, or you can "meet it" in the video recorder plugin in Gazebo. In both cases, HW-accelerated encoding can be set up.</p>
143143
<p>HW acceleration should provide you with higher encoding performance, potentially leaving more CPU power to the rest of your program/simulation, while taking a bit of GPU memory (video encoding uses different chips than 3D graphics or CUDA computations, so performance-wise, the rest of the GPU should be unaffected).</p>
144-
<h1><a class="anchor" id="autotoc_md2"></a>
144+
<h1><a class="anchor" id="configuring-hardware-acceleration"></a>
145145
Configuring hardware acceleration</h1>
146-
<h2><a class="anchor" id="autotoc_md3"></a>
146+
<h2><a class="anchor" id="what-needs-to-be-configured"></a>
147147
What needs to be configured</h2>
148148
<p>In order to get HW accelerated encoding working, you need to get 3 things right:</p>
149149
<ol type="1">
150150
<li>The encoder type</li>
151151
<li>The HW device to be used</li>
152152
<li>Whether to use a specialized HW surface</li>
153153
</ol>
154-
<h2><a class="anchor" id="autotoc_md4"></a>
154+
<h2><a class="anchor" id="autotoc_md1-encoder-types"></a>
155155
1. Encoder types</h2>
156156
<p>The support for HW-accelerated encoding is based on what the local installation of <code>libavcodec</code> (and your hardware) offers. If the libavcodec/FFMpeg your system has doesn't support HW acceleration, you're out of luck until you get a version that supports some. Some information about various aspects of the acceleration support by FFMpeg can be found on their <a href="https://trac.ffmpeg.org/wiki/HWAccelIntro">HWAccelIntro wiki page</a>.</p>
157157
<p>If FFMpeg is correctly installed, you can see the available HW encoders by calling <code>ffmpeg -hide_banner -encoders | grep 264</code>.</p>
@@ -191,7 +191,7 @@ <h2><a class="anchor" id="autotoc_md4"></a>
191191
<li>VA-API: <code>libva-glx2</code>, <code>libva-drm2</code>, maybe also <code>libglvnd0</code></li>
192192
<li>QSV: Unclear, usually works out of the box</li>
193193
</ul>
194-
<h2><a class="anchor" id="autotoc_md5"></a>
194+
<h2><a class="anchor" id="autotoc_md2-device-names"></a>
195195
2. Device names</h2>
196196
<p>If your computer has more GPUs, it is important to specify which one to use. Here are some basic naming rules:</p>
197197
<ul>
@@ -214,22 +214,22 @@ <h2><a class="anchor" id="autotoc_md5"></a>
214214
</ul>
215215
</li>
216216
</ul>
217-
<h2><a class="anchor" id="autotoc_md6"></a>
217+
<h2><a class="anchor" id="autotoc_md3-using-hw-surface"></a>
218218
3. Using HW surface</h2>
219219
<p>The last thing you need to decide is whether the selected encoder should use a HW surface (pixel buffer) or the default CPU-located one. With most encoders, this is just a performance issue and they will work both with CPU and GPU surfaces.</p>
220220
<p>It is best if you perform experiments with HW surface used and not used and compare the performance. Select the one that suits your use case better.</p>
221-
<h2><a class="anchor" id="autotoc_md7"></a>
221+
<h2><a class="anchor" id="putting-it-together---configuration-via-environment-variables"></a>
222222
Putting it together - configuration via environment variables</h2>
223223
<p>To ease configuration of the HW-accelerated encoding, there doesn't have to be explicit support for it in the code using <code>VideoEncoder</code>. The code may concentrate on implementing the recording procedure itself, and completely ignore any HW acceleration of the recording process. Users of the code can then enable the HW acceleration just using these 3 environment variables:</p>
224-
<h3><a class="anchor" id="autotoc_md8"></a>
224+
<h3><a class="anchor" id="gz_video_allowed_encoders"></a>
225225
GZ_VIDEO_ALLOWED_ENCODERS</h3>
226226
<p>This is the main variable that allows the <code>VideoEncoder</code> to probe for supported HW-accelerated encoders. It is a colon-separated list of names described in the table above. Example: <code>GZ_VIDEO_ALLOWED_ENCODERS=NVENC:QSV</code>. Special value <code>ALL</code> means that all encoders should be tried. Special value <code>NONE</code> (or empty value) means that a SW encoder should be used.</p>
227227
<p>If more values are specified, the system will probe all the allowed encoders trying to start them up (if device is specified, then only with the given device). The first allowed encoder that successfully finishes the probe will be used.</p>
228228
<p>The probing mechanism isn't 100% reliable. But it does what's reasonable to do in such an autodetection loop - it checks whether the required/supported device files exist, and if they do (or if there are no device files, as on Windows), the library tries to create an encoding context. If the context is successfully created, the encoder is considered working. Sometimes, something can go wrong in a later stage (e.g. insufficient GPU memory), and that is a kind of thing you have to handle yourself.</p>
229-
<h3><a class="anchor" id="autotoc_md9"></a>
229+
<h3><a class="anchor" id="gz_video_encoder_device"></a>
230230
GZ_VIDEO_ENCODER_DEVICE</h3>
231231
<p>This is a name of the encoder device as specified in the "Device Names" section. If empty, first working device will be used. This auto detection should suffice on single-GPU systems or if you don't care which GPU will be used. If a device is specified, only encoders accepting this device name as an argument will be probed.</p>
232-
<h3><a class="anchor" id="autotoc_md10"></a>
232+
<h3><a class="anchor" id="gz_video_use_hw_surface"></a>
233233
GZ_VIDEO_USE_HW_SURFACE</h3>
234234
<p>This variable has three possible values:</p>
235235
<ul>
@@ -238,7 +238,7 @@ <h3><a class="anchor" id="autotoc_md10"></a>
238238
<li>empty: Let the library guess based on some pre-compiled hints.</li>
239239
</ul>
240240
<p>Refer to section "Using HW surface" for more in-depth description of the meaning of this variable. Usually, leaving it empty should be just fine.</p>
241-
<h2><a class="anchor" id="autotoc_md11"></a>
241+
<h2><a class="anchor" id="configuration-in-code"></a>
242242
Configuration in code</h2>
243243
<p>These values can also be configured in code.</p>
244244
<p>As stated earlier, if you use the standard 6-argument signature of <code>VideoEncoder::Start()</code>, configuration via the above described environment variables will be performed.</p>
@@ -253,7 +253,7 @@ <h2><a class="anchor" id="autotoc_md11"></a>
253253
<div class="line"> std::optional&lt;bool&gt; _useHwSurface = {})</div>
254254
</div><!-- fragment --><p>The three added arguments correspond to the environment variables, but with this signature you can set their values from code (and environment variables will have no effect then). This would be useful if you want to e.g. implement a GUI chooser for the acceleration.</p>
255255
<p>The <code>FlagSet&lt;HWEncoderType&gt;</code> captures a set of allowed encoders. Its value may be e.g. <code>gz::Common::HWEncoderType::QSV | gz::common::HWEncoderType::NVENC</code>.</p>
256-
<h2><a class="anchor" id="autotoc_md12"></a>
256+
<h2><a class="anchor" id="how-do-i-know-its-working"></a>
257257
How do I know it's working</h2>
258258
<p>To make sure you configured the HW acceleration right, you may look at info-level messages where <code>VideoEncoder</code> documents the detected encoder. It may look like:</p>
259259
<div class="fragment"><div class="line">[Msg] Recording started: 3078s (sim time), 42088s (real time)</div>
@@ -292,27 +292,27 @@ <h2><a class="anchor" id="autotoc_md12"></a>
292292
<div class="line">[GUI] [Wrn] [HWEncoder.cc:384] No hardware-accelerated encoder found, falling back to software encoders</div>
293293
<div class="line">[GUI] [Msg] Compatible SW encoder: libx264</div>
294294
<div class="line">[GUI] [Msg] Using encoder libx264</div>
295-
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md13"></a>
295+
</div><!-- fragment --><h1><a class="anchor" id="examples"></a>
296296
Examples</h1>
297297
<p>Here are a few ready-made examples which might or might not work for you right-away. Just give them a try and dig deeper in the configuration if something is wrong.</p>
298-
<h2><a class="anchor" id="autotoc_md14"></a>
298+
<h2><a class="anchor" id="linuxwin--intel-gpu"></a>
299299
Linux/Win + Intel GPU</h2>
300300
<pre class="fragment">GZ_VIDEO_ALLOWED_ENCODERS=QSV
301-
</pre> <h2><a class="anchor" id="autotoc_md15"></a>
301+
</pre> <h2><a class="anchor" id="linuxwin--nvidia-gpu"></a>
302302
Linux/Win + NVidia GPU</h2>
303303
<pre class="fragment">GZ_VIDEO_ALLOWED_ENCODERS=NVENC
304-
</pre> <h2><a class="anchor" id="autotoc_md16"></a>
304+
</pre> <h2><a class="anchor" id="linux--intelnvidia-gpu"></a>
305305
Linux + Intel/NVidia GPU</h2>
306306
<pre class="fragment">GZ_VIDEO_ALLOWED_ENCODERS=VAAPI
307-
</pre> <h2><a class="anchor" id="autotoc_md17"></a>
307+
</pre> <h2><a class="anchor" id="linux-nvidia-multi-gpu-machine"></a>
308308
Linux NVidia Multi-GPU machine</h2>
309309
<pre class="fragment">GZ_VIDEO_ALLOWED_ENCODERS=NVENC GZ_VIDEO_ENCODER_DEVICE=/dev/nvidia2
310-
</pre> <h1><a class="anchor" id="autotoc_md18"></a>
310+
</pre> <h1><a class="anchor" id="caveats"></a>
311311
Caveats</h1>
312-
<h2><a class="anchor" id="autotoc_md19"></a>
312+
<h2><a class="anchor" id="ffmpeg-on-windows-via-conda"></a>
313313
FFMpeg on Windows via Conda</h2>
314314
<p>The current distribution of FFMpeg via Conda for Windows does not include the h264_qsv encoder. It only has h264_nvenc. This means that using Intel GPUs for HW acceleration is not possible out of the box. A possible solution would be to build a custom build of ffmpeg in the workspace with gz-common. Pull requests with the relevant tutorial are welcome.</p>
315-
<h2><a class="anchor" id="autotoc_md20"></a>
315+
<h2><a class="anchor" id="nvenc-per-machine-limit"></a>
316316
NVEnc per-machine limit</h2>
317317
<p>If you have a multi-GPU station with desktop-class (not server-class) GPUs, you will run into an artificial limitation from NVidia. You can only run 3 concurrent encoding sessions on one computer, no matter how many GPUs you have. The computer can even have 8 GPUs, but you will only be able to encode 3 videos at a time. The exact maxima of encoding sessions are described in <a href="https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new">this NVidia support page</a>.</p>
318318
<p>To make things worse, there is no API that would tell you the number of currently running NVEnc sessions. The only way to find out you're launching the fourth is trying to start encoding and getting a memory allocation error. This library catches this error and writes a lengthy description of what might have just happened (either really low memory or this artificial limit). Unfortunately, when you start the doomed fourth encoding session, all the three "legal" sessions will crash. This might be really troublesome on e.g. multi-user systems when you don't even know which jobs of the other users are using NVEnc.</p>

api/common/6/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h2>API Reference</h2>
139139
</div><!--header-->
140140
<div class="contents">
141141
<div class="textblock"><p><a class="anchor" id="md_api"></a> Gazebo Common is a component in Gazebo, a set of libraries designed to rapidly develop robot and simulation applications.</p>
142-
<h1><a class="anchor" id="autotoc_md1"></a>
142+
<h1><a class="anchor" id="license"></a>
143143
License</h1>
144144
<p>The code associated with this documentation is licensed under an <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 License</a>.</p>
145145
<p>This documentation is licensed under a <a href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. </p>

api/common/6/install.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,29 +142,29 @@ <h2>API Reference</h2>
142142
<p>These instructions are for installing only Gazebo Common. If you're interested in using all the Gazebo libraries, check out this <a href="https://gazebosim.org/docs/latest/install">Gazebo installation</a>.</p>
143143
<p>We recommend following the Binary Installation instructions to get up and running as quickly and painlessly as possible.</p>
144144
<p>The Source Installation instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution.</p>
145-
<h1><a class="anchor" id="autotoc_md21"></a>
145+
<h1><a class="anchor" id="binary-installation"></a>
146146
Binary Installation</h1>
147-
<h2><a class="anchor" id="autotoc_md22"></a>
147+
<h2><a class="anchor" id="ubuntu"></a>
148148
Ubuntu</h2>
149149
<p>On Ubuntu systems, <code>apt-get</code> can be used to install <code>gz-common</code>: </p><div class="fragment"><div class="line">sudo apt install libgz-common&lt;#&gt;-dev</div>
150150
</div><!-- fragment --><p>Be sure to replace <code>&lt;#&gt;</code> with a number value, such as 2 or 3, depending on which version you need.</p>
151-
<h3><a class="anchor" id="autotoc_md23"></a>
151+
<h3><a class="anchor" id="macos"></a>
152152
macOS</h3>
153153
<p>On macOS, add OSRF packages: </p><div class="fragment"><div class="line">/bin/bash&quot;, &quot;-c&quot;, &#39;/bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;</div>
154154
<div class="line">brew tap osrf/simulation</div>
155155
</div><!-- fragment --><p>Install Gazebo Common: </p><div class="fragment"><div class="line">brew install gz-common&lt;#&gt;</div>
156156
</div><!-- fragment --><p>Be sure to replace <code>&lt;#&gt;</code> with a number value, such as 3 or 4, depending on which version you need.</p>
157-
<h2><a class="anchor" id="autotoc_md24"></a>
157+
<h2><a class="anchor" id="windows"></a>
158158
Windows</h2>
159159
<p>Install <a href="https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html">Conda package management system</a>. Miniconda suffices.</p>
160160
<p>Create if necessary, and activate a Conda environment: </p><div class="fragment"><div class="line">conda create -n gz-ws</div>
161161
<div class="line">conda activate gz-ws</div>
162162
</div><!-- fragment --><p>Install <code>gz-common</code>: </p><div class="fragment"><div class="line">conda install libgz-common&lt;#&gt; --channel conda-forge</div>
163163
</div><!-- fragment --><p>Be sure to replace <code>&lt;#&gt;</code> with a number value, such as 2 or 3, depending on which version you need.</p>
164-
<h1><a class="anchor" id="autotoc_md25"></a>
164+
<h1><a class="anchor" id="source-installation"></a>
165165
Source Installation</h1>
166166
<p>Source installation can be performed by first installing the necessary prerequisites followed by building from source.</p>
167-
<h2><a class="anchor" id="autotoc_md26"></a>
167+
<h2><a class="anchor" id="prerequisites"></a>
168168
Prerequisites</h2>
169169
<p>Gazebo Common requires:</p>
170170
<ul>
@@ -187,7 +187,7 @@ <h2><a class="anchor" id="autotoc_md26"></a>
187187
<ul>
188188
<li><a href="https://gdal.org/">gdal</a></li>
189189
</ul>
190-
<h3><a class="anchor" id="autotoc_md27"></a>
190+
<h3><a class="anchor" id="windows-1"></a>
191191
Windows</h3>
192192
<p>First, follow the <a href="https://github.com/gazebosim/gz-cmake">gz-cmake</a> tutorial for installing Conda, Visual Studio, CMake, etc., prerequisites, and creating a Conda environment.</p>
193193
<p>Navigate to <code>condabin</code> if necessary to use the <code>conda</code> command (i.e., if Conda is not in your <code>PATH</code> environment variable. You can find the location of <code>condabin</code> in Anaconda Prompt, <code>where conda</code>).</p>
@@ -196,9 +196,9 @@ <h3><a class="anchor" id="autotoc_md27"></a>
196196
</div><!-- fragment --><p>Install Gazebo dependencies:</p>
197197
<p>You can view available versions and their dependencies: </p><div class="fragment"><div class="line">conda search libgz-common* --channel conda-forge --info</div>
198198
</div><!-- fragment --><p>Install dependencies, replacing <code>&lt;#&gt;</code> with the desired versions: </p><div class="fragment"><div class="line">conda install libgz-cmake&lt;#&gt; libgz-math&lt;#&gt; --channel conda-forge</div>
199-
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md28"></a>
199+
</div><!-- fragment --><h2><a class="anchor" id="build-from-source"></a>
200200
Build from Source</h2>
201-
<h3><a class="anchor" id="autotoc_md29"></a>
201+
<h3><a class="anchor" id="ubuntu-1"></a>
202202
Ubuntu</h3>
203203
<ol type="1">
204204
<li>Clone the repository <div class="fragment"><div class="line">git clone https://github.com/gazebosim/gz-common</div>
@@ -212,7 +212,7 @@ <h3><a class="anchor" id="autotoc_md29"></a>
212212
<li>Optionally, install <div class="fragment"><div class="line">sudo make install</div>
213213
</div><!-- fragment --></li>
214214
</ol>
215-
<h3><a class="anchor" id="autotoc_md30"></a>
215+
<h3><a class="anchor" id="macos-1"></a>
216216
macOS</h3>
217217
<ol type="1">
218218
<li>Clone the repository <div class="fragment"><div class="line">git clone https://github.com/gazebosim/gz-common -b gz-common&lt;#&gt;</div>
@@ -228,7 +228,7 @@ <h3><a class="anchor" id="autotoc_md30"></a>
228228
<li>Optionally, install <div class="fragment"><div class="line">sudo make install</div>
229229
</div><!-- fragment --></li>
230230
</ol>
231-
<h3><a class="anchor" id="autotoc_md31"></a>
231+
<h3><a class="anchor" id="windows-2"></a>
232232
Windows</h3>
233233
<p>This assumes you have created and activated a Conda environment while installing the Prerequisites.</p>
234234
<ol type="1">
@@ -245,7 +245,7 @@ <h3><a class="anchor" id="autotoc_md31"></a>
245245
<li>Optionally, install <div class="fragment"><div class="line">cmake --install . --config Release</div>
246246
</div><!-- fragment --></li>
247247
</ol>
248-
<h1><a class="anchor" id="autotoc_md32"></a>
248+
<h1><a class="anchor" id="documentation"></a>
249249
Documentation</h1>
250250
<p>API and tutorials can be found at <a href="https://gazebosim.org/libs/common">https://gazebosim.org/libs/common</a>.</p>
251251
<p>You can also generate the documentation from a clone of this repository by following these steps.</p>
@@ -263,7 +263,7 @@ <h1><a class="anchor" id="autotoc_md32"></a>
263263
<li>View the documentation by running the following command from the build directory. <div class="fragment"><div class="line">firefox doxygen/html/index.html</div>
264264
</div><!-- fragment --></li>
265265
</ol>
266-
<h1><a class="anchor" id="autotoc_md33"></a>
266+
<h1><a class="anchor" id="testing"></a>
267267
Testing</h1>
268268
<p>Follow these steps to run tests and static code analysis in your clone of this repository.</p>
269269
<ol type="1">

0 commit comments

Comments
 (0)