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