Skip to content

Commit 70f07ca

Browse files
committed
Improving HW-ACCEL documentation
1 parent cdb4ae5 commit 70f07ca

File tree

2 files changed

+73
-34
lines changed

2 files changed

+73
-34
lines changed

doc/HW-ACCEL.md

Lines changed: 61 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
## Hardware Acceleration
22

3-
Observations for developers wanting to make hardware acceleration work.
4-
5-
*All observations are for Linux (but contributions welcome).*
3+
OpenShot now has experimental support for hardware acceleration, which uses 1 (or more)
4+
graphics cards to offload some of the work for both decoding and encoding. This is
5+
very new and experimental (as of May 2019), but we look forward to "accelerating"
6+
our support for this in the future!
7+
8+
The following table summarizes our current level of support:
9+
10+
| | Linux Decode | Linux Encode | Mac Decode | Mac Encode | Windows Decode | Windows Encode | Notes |
11+
|--------------------|--------------|--------------|------------|------------|----------------------|----------------|----------------|
12+
| VA-API | Verified | Verified | - | - | - | - | Linux Only |
13+
| VDPAU | Verified | Verified | - | - | - | - | Linux Only |
14+
| CUDA (NVDEC/NVENC) | Verified | Verified | - | - | - | Verified | Cross Platform |
15+
| VideoToolBox | - | - | Verified | Crashes | - | - | Mac Only |
16+
| DXVA2 | - | - | - | - | Fails (green frames) | Verified | Windows Only |
17+
| D3D11VA | - | - | - | - | Fails (green frames) | - | Windows Only |
18+
| QSV | Fails | Fails | Fails | Fails | Fails | Fails | Cross Platform |
619

720
## Supported FFmpeg Versions
821

9-
* HW accel is supported from ffmpeg version 3.2 (3.3 for nVidia drivers)
10-
* HW accel was removed for nVidia drivers in Ubuntu for ffmpeg 4+
11-
* I could not manage to build a version of ffmpeg 4.1 with the nVidia SDK
12-
that worked with nVidia cards. There might be a problem in ffmpeg 4+
22+
* HW accel is supported from FFmpeg version 3.2 (3.3 for nVidia drivers)
23+
* HW accel was removed for nVidia drivers in Ubuntu for FFmpeg 4+
24+
* We could not manage to build a version of FFmpeg 4.1 with the nVidia SDK
25+
that worked with nVidia cards. There might be a problem in FFmpeg 4+
1326
that prohibits this.
1427

15-
**Notice:** The ffmpeg versions of Ubuntu and PPAs for Ubuntu show the
16-
same behaviour. ffmpeg 3 has working nVidia hardware acceleration while
17-
ffmpeg 4+ has no support for nVidia hardware acceleration
28+
**Notice:** The FFmpeg versions of Ubuntu and PPAs for Ubuntu show the
29+
same behaviour. FFmpeg 3 has working nVidia hardware acceleration while
30+
FFmpeg 4+ has no support for nVidia hardware acceleration
1831
included.
1932

2033
## OpenShot Settings
@@ -26,10 +39,19 @@ the various hardware acceleration features.
2639
/// Use video codec for faster video decoding (if supported)
2740
int HARDWARE_DECODER = 0;
2841
42+
/* 0 - No acceleration
43+
1 - Linux VA-API
44+
2 - nVidia NVDEC
45+
3 - Windows D3D9
46+
4 - Windows D3D11
47+
5 - MacOS / VideoToolBox
48+
6 - Linux VDPAU
49+
7 - Intel QSV */
50+
2951
/// Number of threads of OpenMP
3052
int OMP_THREADS = 12;
3153
32-
/// Number of threads that ffmpeg uses
54+
/// Number of threads that FFmpeg uses
3355
int FF_THREADS = 8;
3456
3557
/// Maximum rows that hardware decode can handle
@@ -38,10 +60,10 @@ int DE_LIMIT_HEIGHT_MAX = 1100;
3860
/// Maximum columns that hardware decode can handle
3961
int DE_LIMIT_WIDTH_MAX = 1950;
4062
41-
/// Which GPU to use to decode (0 is the first)
63+
/// Which GPU to use to decode (0 is the first, LINUX ONLY)
4264
int HW_DE_DEVICE_SET = 0;
4365
44-
/// Which GPU to use to encode (0 is the first)
66+
/// Which GPU to use to encode (0 is the first, LINUX ONLY)
4567
int HW_EN_DEVICE_SET = 0;
4668
```
4769

@@ -67,38 +89,44 @@ of effects could be implemented (contributions welcome).
6789
If the computer has multiple graphics cards installed, you can choose which
6890
should be used by libopenshot. Also, you can optionally use one card for
6991
decoding and the other for encoding (if both cards support acceleration).
92+
This is currently only supported on Linux, due to the device name FFmpeg
93+
expects (i.e. **/dev/dri/render128**). Contributions welcome if anyone can
94+
determine what string format to pass for Windows and Mac.
7095

7196
## Help Us Improve Hardware Support
7297

7398
This information might be wrong, and we would love to continue improving
7499
our support for hardware acceleration in OpenShot. Please help us update
75-
this document if you find an error or discover some new information.
100+
this document if you find an error or discover new and/or useful information.
76101

77-
**Desperately Needed:** The manual at:
102+
**FFmpeg 4 + nVidia** The manual at:
78103
https://www.tal.org/tutorials/ffmpeg_nvidia_encode
79-
works pretty well. I could compile and install a version of ffmpeg 4.1.3
104+
works pretty well. We could compile and install a version of FFmpeg 4.1.3
80105
on Mint 19.1 that supports the GPU on nVidia cards. A version of openshot
81106
with hardware support using these libraries could use the nVidia GPU.
82-
(A way to compile ffmpeg 4.0 and up with working nVidia
83-
hardware acceleration support on Ubuntu Linux!)
84-
85-
**BUG:** Hardware supported decoding still has a bug. The speed gains with
86-
decoding are by far not as great as with encoding. In case hardware accelerated
87-
decoding does not work disable it. Hardware acceleration might also break
88-
because of graphics drivers that have bugs.
89-
90-
**Needed:** A way to get the options and limits of the GPU, like
91-
supported codecs and the supported dimensions (width and height).
92107

93-
**Further improvement:** Right now the frame can be decoded on the GPU but the
94-
frame is then copied to CPU memory. Before encoding the frame is then
95-
copied to GPU memory for encoding. That is necessary because the modifications
96-
are done by the CPU. Using the GPU for that too will make it possible to do
97-
away with these two copies. A possible solution would be to use Vulkan compute
98-
which would be available on Linux and Windows natively and on MacOS via MoltenVK.
108+
**BUG:** Hardware supported decoding still has some bugs (as you can see from
109+
the chart above). Also, the speed gains with decoding are not as great
110+
as with encoding. Currently, if hardware decoding fails, there is no
111+
fallback (you either get green frames or an "invalid file" error in OpenShot).
112+
This needs to be improved to successfully fall-back to software decoding.
113+
114+
**Needed:**
115+
* A way to get options and limits of the GPU, such as
116+
supported dimensions (width and height).
117+
* A way to list the actual Graphic Cards available to FFmpeg (for the
118+
user to choose which card for decoding and encoding, as opposed
119+
to "Graphics Card X")
120+
121+
**Further improvement:** Right now the frame can be decoded on the GPU, but the
122+
frame is then copied to CPU memory for modifications. It is then copied back to
123+
GPU memory for encoding. Using the GPU for both decoding and modifications
124+
will make it possible to do away with these two copies. A possible solution would
125+
be to use Vulkan compute which would be available on Linux and Windows natively
126+
and on MacOS via MoltenVK.
99127

100128
## Credit
101129

102130
A big thanks to Peter M (https://github.com/eisneinechse) for all his work
103-
on integrating hardware accelleration into libopenshot! The community thanks
131+
on integrating hardware acceleration into libopenshot! The community thanks
104132
you for this major contribution!

include/Settings.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ namespace openshot {
7676
static Settings * m_pInstance;
7777

7878
public:
79-
/// Use video codec for faster video decoding (if supported)
79+
/**
80+
* @brief Use video codec for faster video decoding (if supported)
81+
*
82+
* 0 - No acceleration,
83+
* 1 - Linux VA-API,
84+
* 2 - nVidia NVDEC,
85+
* 3 - Windows D3D9,
86+
* 4 - Windows D3D11,
87+
* 5 - MacOS / VideoToolBox,
88+
* 6 - Linux VDPAU,
89+
* 7 - Intel QSV
90+
*/
8091
int HARDWARE_DECODER = 0;
8192

8293
/// Scale mode used in FFmpeg decoding and encoding (used as an optimization for faster previews)

0 commit comments

Comments
 (0)