1 ## Hardware Acceleration
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!
8 The following table summarizes our current level of support:
10 | | Linux Decode | Linux Encode | Mac Decode | Mac Encode | Windows Decode | Windows Encode | Notes |
11 |--------------------|:---------------:|:--------------:|:----------:|:--------------:|:--------------:|:--------------:|------------------|
12 | VA-API | ✔️ | ✔️ | - | - | - | - | *Linux Only* |
13 | VDPAU | ✔️ <sup>1</sup> | ✅ <sup>2</sup> | - | - | - | - | *Linux Only* |
14 | CUDA (NVDEC/NVENC) | ❌ <sup>3</sup> | ✔️ | - | - | - | ✔️ | *Cross Platform* |
15 | VideoToolBox | - | - | ✔️ | ❌ <sup>4</sup> | - | - | *Mac Only* |
16 | DXVA2 | - | - | - | - | ❌ <sup>3</sup> | - | *Windows Only* |
17 | D3D11VA | - | - | - | - | ❌ <sup>3</sup> | - | *Windows Only* |
18 | QSV | ❌ <sup>3</sup> | ❌ | ❌ | ❌ | ❌ | ❌ | *Cross Platform* |
22 1. VDPAU for some reason needs a card number one higher than it really is
23 2. VDPAU is a decoder only
24 3. Green frames (pixel data not correctly tranferred back to system memory)
27 ## Supported FFmpeg Versions
29 * HW accel is supported from FFmpeg version 3.2 (3.3 for nVidia drivers)
30 * HW accel was removed for nVidia drivers in Ubuntu for FFmpeg 4+
32 **Notice:** The FFmpeg versions of Ubuntu and PPAs for Ubuntu show the
33 same behaviour. FFmpeg 3 has working nVidia hardware acceleration while
34 FFmpeg 4+ has no support for nVidia hardware acceleration
39 The following settings are use by libopenshot to enable, disable, and control
40 the various hardware acceleration features.
43 /// Use video codec for faster video decoding (if supported)
44 int HARDWARE_DECODER = 0;
46 /* 0 - No acceleration
51 5 - MacOS / VideoToolBox
55 /// Number of threads of OpenMP
58 /// Number of threads that FFmpeg uses
61 /// Maximum rows that hardware decode can handle
62 int DE_LIMIT_HEIGHT_MAX = 1100;
64 /// Maximum columns that hardware decode can handle
65 int DE_LIMIT_WIDTH_MAX = 1950;
67 /// Which GPU to use to decode (0 is the first, LINUX ONLY)
68 int HW_DE_DEVICE_SET = 0;
70 /// Which GPU to use to encode (0 is the first, LINUX ONLY)
71 int HW_EN_DEVICE_SET = 0;
74 ## Libva / VA-API (Video Acceleration API)
76 The correct version of libva is needed (libva in Ubuntu 16.04 or libva2
77 in Ubuntu 18.04) for the AppImage to work with hardware acceleration.
78 An AppImage that works on both systems (supporting libva and libva2),
79 might be possible when no libva is included in the AppImage.
81 * vaapi is working for intel and AMD
82 * vaapi is working for decode only for nouveau
83 * nVidia driver is working for export only
85 ## AMD Graphics Cards (RadeonOpenCompute/ROCm)
87 Decoding and encoding on the (AMD) GPU is possible with the default drivers.
88 On systems where ROCm is installed and run a future use for GPU acceleration
89 of effects could be implemented (contributions welcome).
91 ## Multiple Graphics Cards
93 If the computer has multiple graphics cards installed, you can choose which
94 should be used by libopenshot. Also, you can optionally use one card for
95 decoding and the other for encoding (if both cards support acceleration).
96 This is currently only supported on Linux, due to the device name FFmpeg
97 expects (i.e. **/dev/dri/render128**). Contributions welcome if anyone can
98 determine what string format to pass for Windows and Mac.
100 ## Help Us Improve Hardware Support
102 This information might be wrong, and we would love to continue improving
103 our support for hardware acceleration in OpenShot. Please help us update
104 this document if you find an error or discover new and/or useful information.
106 **FFmpeg 4 + nVidia** The manual at:
107 https://www.tal.org/tutorials/ffmpeg_nvidia_encode
108 works pretty well. We could compile and install a version of FFmpeg 4.1.3
109 on Mint 19.1 that supports the GPU on nVidia cards. A version of openshot
110 with hardware support using these libraries could use the nVidia GPU.
112 **BUG:** Hardware supported decoding still has some bugs (as you can see from
113 the chart above). Also, the speed gains with decoding are not as great
114 as with encoding. Currently, if hardware decoding fails, there is no
115 fallback (you either get green frames or an "invalid file" error in OpenShot).
116 This needs to be improved to successfully fall-back to software decoding.
119 * A way to get options and limits of the GPU, such as
120 supported dimensions (width and height).
121 * A way to list the actual Graphic Cards available to FFmpeg (for the
122 user to choose which card for decoding and encoding, as opposed
123 to "Graphics Card X")
125 **Further improvement:** Right now the frame can be decoded on the GPU, but the
126 frame is then copied to CPU memory for modifications. It is then copied back to
127 GPU memory for encoding. Using the GPU for both decoding and modifications
128 will make it possible to do away with these two copies. A possible solution would
129 be to use Vulkan compute which would be available on Linux and Windows natively
130 and on MacOS via MoltenVK.
134 A big thanks to Peter M (https://github.com/eisneinechse) for all his work
135 on integrating hardware acceleration into libopenshot! The community thanks
136 you for this major contribution!