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+
1326that 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
1831included.
1932
2033## OpenShot Settings
@@ -26,10 +39,19 @@ the various hardware acceleration features.
2639/// Use video codec for faster video decoding (if supported)
2740int 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
3052int OMP_THREADS = 12;
3153
32- /// Number of threads that ffmpeg uses
54+ /// Number of threads that FFmpeg uses
3355int 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
3961int 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 )
4264int 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 )
4567int HW_EN_DEVICE_SET = 0;
4668```
4769
@@ -67,38 +89,44 @@ of effects could be implemented (contributions welcome).
6789If the computer has multiple graphics cards installed, you can choose which
6890should be used by libopenshot. Also, you can optionally use one card for
6991decoding 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
7398This information might be wrong, and we would love to continue improving
7499our 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:
78103https://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
80105on Mint 19.1 that supports the GPU on nVidia cards. A version of openshot
81106with 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
102130A 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
104132you for this major contribution!
0 commit comments