Changes between Version 52 and Version 53 of HWAccelIntro
- Timestamp:
- Jul 25, 2017, 8:13:37 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HWAccelIntro
v52 v53 1 1 [[PageOutline(2, Contents)]] 2 2 3 Many platforms offer access to dedicated hardware to perform a range of video-related tasks. Using such hardware allows some operations like decoding, encoding or filtering to be completed faster or using less of other resources (particularly CPU), but may give different or inferior results, or impose additional restrictions which are not present when using software only. On PC-like platforms, video hardware is typically integrated into a GPU (from AMD, Intel or Nvidia), while on mobile SoC-type platforms it is generally an independent IP core (many different vendors).3 Many platforms offer access to dedicated hardware to perform a range of video-related tasks. Using such hardware allows some operations like decoding, encoding or filtering to be completed faster or using less of other resources (particularly CPU), but may give different or inferior results, or impose additional restrictions which are not present when using software only. On PC-like platforms, video hardware is typically integrated into a GPU (from AMD, Intel or NVIDIA), while on mobile SoC-type platforms it is generally an independent IP core (many different vendors). 4 4 5 Hardware decoders will generate equivalent output to software decoders, but may use less power and CPU to do so. Feature support varies - for more complex codecs with many different profiles, hardware decoders rarely implement all of them (for example, hardware decoders tend not to implement anything beyond YUV 4:2:0 at 8-bit depth for H.264). A common feature of many hardware decoders to be able to generate output in hardware surfaces suitable for use by other components (with discrete graphics cards, this means surfaces in the memory on the card rather than in system memory) -this is often useful for playback, as no further copying is required before rendering the output, and in some cases it can also be used with encoders supporting hardware surface input to avoid any copying at all in transcode cases.5 Hardware decoders will generate equivalent output to software decoders, but may use less power and CPU to do so. Feature support varies – for more complex codecs with many different profiles, hardware decoders rarely implement all of them (for example, hardware decoders tend not to implement anything beyond YUV 4:2:0 at 8-bit depth for H.264). A common feature of many hardware decoders to be able to generate output in hardware surfaces suitable for use by other components (with discrete graphics cards, this means surfaces in the memory on the card rather than in system memory) – this is often useful for playback, as no further copying is required before rendering the output, and in some cases it can also be used with encoders supporting hardware surface input to avoid any copying at all in transcode cases. 6 6 7 Hardware encoders typically generate output of significantly lower quality than good software encoders like x264, but are generally faster and do not use much CPU resource. (That is, they require a higher bitrate to make output with the same perceptual quality, or they make output with a lower perceptual quality at the same bitrate.)7 Hardware encoders typically generate output of significantly lower quality than good software encoders like x264, but are generally faster and do not use much CPU resource. (That is, they require a higher bitrate to make output with the same perceptual quality, or they make output with a lower perceptual quality at the same bitrate.) 8 8 9 Systems with decode and/or encode capability may also offer access to other related filtering features. Things like scaling and deinterlacing are common, other postprocessing may be available depending on the system.Where hardware surfaces are usable, these filters will generally act on them rather than on normal frames in system memory.9 Systems with decode and/or encode capability may also offer access to other related filtering features. Things like scaling and deinterlacing are common, other postprocessing may be available depending on the system. Where hardware surfaces are usable, these filters will generally act on them rather than on normal frames in system memory. 10 10 11 There are a lot of different APIs of varying standardisation status available. FFmpeg offers access to many of these, with varying support.11 There are a lot of different APIs of varying standardisation status available. FFmpeg offers access to many of these, with varying support. 12 12 13 13 … … 15 15 16 16 || ||||||= Linux =||||||= Windows =||= Android =||||= Apple =||= Other =|| 17 || ||= AMD =||= Intel =||= N vidia =||= AMD =||= Intel =||= Nvidia=||= =||= macOS =||= iOS =||= Raspberry Pi =||17 || ||= AMD =||= Intel =||= NVIDIA =||= AMD =||= Intel =||= NVIDIA =||= =||= macOS =||= iOS =||= Raspberry Pi =|| 18 18 || CUDA / CUVID / NVENC || N || N || Y || N || N || Y || N || N || N || N || 19 19 || Direct3D 11 || N || N || N || Y || Y || Y || N || N || N || N || … … 68 68 Internal hwaccel decoders are enabled via the `-hwaccel` option. The software decoder starts normally, but if it detects a stream which is decodable in hardware then it will attempt to delegate all significant processing to that hardware. If the stream is not decodable in hardware (for example, it is an unsupported codec or profile) then it will still be decoded in software automatically. If the hardware requires a particular device to function (or needs to distinguish between multiple devices, say if several graphics cards are available) then one can be selected using `-hwaccel_device`. 69 69 70 External wrapper decoders are used by setting a specific decoder with the `-codec:v` option. Typically they are named `codec_api` (for example: `h264_cuvid`). These decoders require the codec to be known in advance, and do not support any fallback to software if the stream is not supported.70 External wrapper decoders are used by setting a specific decoder with the `-codec:v` option. Typically they are named `codec_api` (for example: `h264_cuvid`). These decoders require the codec to be known in advance, and do not support any fallback to software if the stream is not supported. 71 71 72 Encoder wrappers are selected by `-codec:v`. Encoders generally have lots of options -look at the documentation for the particular encoder for details.72 Encoder wrappers are selected by `-codec:v`. Encoders generally have lots of options – look at the documentation for the particular encoder for details. 73 73 74 Hardware filters can be used in a filter graph like any other filter. Note, however, that they may not support any formats in common with software filters -in such cases it may be necessary to make use of `hwupload` and `hwdownload` filter instances to move frame data between hardware surfaces and normal memory.74 Hardware filters can be used in a filter graph like any other filter. Note, however, that they may not support any formats in common with software filters – in such cases it may be necessary to make use of `hwupload` and `hwdownload` filter instances to move frame data between hardware surfaces and normal memory. 75 75 76 76 77 77 == VDPAU == 78 [http://http.download.nvidia.com/XFree86/vdpau/doxygen/html/index.html Video Decode and Presentation API for Unix]. Developed by NVidia for UNIX/Linux systems. To enable this you typically need the libvdpau development package in your distribution, and a compatible graphic card. 78 79 [http://http.download.nvidia.com/XFree86/vdpau/doxygen/html/index.html Video Decode and Presentation API for Unix]. Developed by NVIDIA for Unix/Linux systems. To enable this you typically need the `libvdpau` development package in your distribution, and a compatible graphics card. 79 80 80 81 Note that VDPAU cannot be used to decode frames in memory, the compressed frames are sent by libavcodec to the GPU device supported by VDPAU and then the decoded image can be accessed using the VDPAU API. This is not done automatically by FFmpeg, but must be done at the application level (check for example the {{{ffmpeg_vdpau.c}}} file used by {{{ffmpeg.c}}}). Also, note that with this API it is not possible to move the decoded frame back to RAM, for example in case you need to encode again the decoded frame (e.g. when doing transcoding on a server). … … 86 87 Video Acceleration API (VAAPI) is a non-proprietary and royalty-free open source software library ("libva") and API specification, initially developed by Intel but can be used in combination with other devices. 87 88 88 It can be used to access the Quick Sync hardware in Intel GPUs and the UVD/VCE hardware in AMD GPUs. See [wiki:Hardware/VAAPI VAAPI].89 It can be used to access the Quick Sync hardware in Intel GPUs and the UVD/VCE hardware in AMD GPUs. See [wiki:Hardware/VAAPI VAAPI]. 89 90 90 91 == DXVA2 == … … 95 96 http://msdn.microsoft.com/en-us/library/windows/desktop/cc307941%28v=vs.85%29.aspx 96 97 97 Several decoders are currently supported, in particular H.264, MPEG 2, VC1 and WMV3.98 Several decoders are currently supported, in particular H.264, MPEG-2, VC-1 and WMV 3. 98 99 99 100 DXVA2 hardware acceleration only works on Windows. In order to build FFmpeg with DXVA2 support, you need to install the dxva2api.h header. 100 For MinGW this can be done by downloading the header maintained by VLC:101 For MinGW this can be done by [http://download.videolan.org/pub/contrib/dxva2api.h downloading the header maintained by VLC] and installing it in the include patch (for example in {{{/usr/include/}}}). 101 102 102 http://download.videolan.org/pub/contrib/dxva2api.h 103 104 and installing it in the include patch (for example in {{{/usr/include/}}}). 105 106 For MinGW64, the dxva2api.h is provided by default. One way to install mingw-w64 is through a {{{pacman}}} repository, and can be installed using one of the two following commands, depending on the architecture: 103 For MinGW64, `dxva2api.h` is provided by default. One way to install mingw-w64 is through a {{{pacman}}} repository, and can be installed using one of the two following commands, depending on the architecture: 107 104 {{{ 108 105 pacman -S mingw-w64-i686-gcc … … 120 117 == VDA == 121 118 122 Video Decoding API, only supported on MAC. H.264 decoding is available in FFmpeg/libavcodec. 123 124 Developers documentation: 125 https://developer.apple.com/library/mac/technotes/tn2267/_index.html 119 [https://developer.apple.com/library/mac/technotes/tn2267/_index.html Video Decode Acceleration Framework], only supported on macOS. H.264 decoding is available in FFmpeg/libavcodec. 126 120 127 121 == NVENC == … … 133 127 * {{{ffmpeg}}} configured without {{{--disable-nvenc}}} 134 128 135 Visit [https://developer.nvidia.com/nvidia-video-codec-sdk NVIDIA Video Codec SDK] to download the SDK and to read more about the supported GPUs and supported drivers.129 Download the [https://developer.nvidia.com/nvidia-video-codec-sdk NVIDIA Video Codec SDK], and check the website for more info on the supported GPUs and drivers. 136 130 137 131 Usage example: 138 {{{ 132 {{{ 139 133 ffmpeg -i input -c:v h264_nvenc -profile high444p -pixel_format yuv444p -preset default output.mp4 140 134 }}} … … 149 143 == CUDA/CUVID/NvDecode == 150 144 151 CUVID, which is also called nvdec by N vidianow, can be used for decoding on Windows and Linux.145 CUVID, which is also called nvdec by NVIDIA now, can be used for decoding on Windows and Linux. 152 146 In combination with nvenc it offers full hardware transcoding. 153 147 154 CUVID offers decoders for H 264, HEVC, MJPEG, mpeg1/2/4, vp8/9, vc1.148 CUVID offers decoders for H.264, HEVC, MJPEG, MPEG-1/2/4, VP8/VP9, VC-1. 155 149 Codec support varies by hardware. The full set of codecs being available only on Pascal hardware, which adds VP9 and 10 bit support. 156 150 157 While decoding 10 bit video is supported, it is not possible to do full hardware transcoding currently ( See the partial hardware example below).151 While decoding 10 bit video is supported, it is not possible to do full hardware transcoding currently (see the partial hardware example below). 158 152 159 153 Sample decode using CUVID, the cuvid decoder copies the frames to system memory in this case: … … 180 174 == libmfx == 181 175 182 libmfx is a proprietary library from Intel for use of Quick Sync hardware on both Linux and Windows. On Windows it is the primary way to use more advanced functions beyond those accessible via DXVA2/D3D11VA, particularly encode.On Linux it has a very restricted feature set and is hard to use, but may be helpful for some use-cases desiring maximum throughput.176 libmfx is a proprietary library from Intel for use of Quick Sync hardware on both Linux and Windows. On Windows it is the primary way to use more advanced functions beyond those accessible via DXVA2/D3D11VA, particularly encode. On Linux it has a very restricted feature set and is hard to use, but may be helpful for some use-cases desiring maximum throughput. 183 177 184 178 See [wiki:Hardware/QuickSync QuickSync]. … … 186 180 == OpenCL == 187 181 188 Official website: 189 190 https://www.khronos.org/opencl/ 191 192 Currently only used in filtering (deshake and unsharp filters). In order to use OpenCL code you need to enable the build with {{{--enable-opencl}}}. An API to use OpenCL API from FFmpeg is provided in libavutil/opencl.h. No decoding/encoding is currently supported (yet). 182 [https://www.khronos.org/opencl/ OpenCL] is currently only used for filtering (deshake and unsharp filters). In order to use OpenCL code you need to enable the build with {{{--enable-opencl}}}. An API to use OpenCL API from FFmpeg is provided in `libavutil/opencl.h`. No decoding/encoding is currently supported (yet). 193 183 194 184 For enable-opencl to work you need to basically install your local graphics cards drivers, as well as SDK, then use its .lib files and headers. … … 198 188 AMD UVD is usable for decode via VDPAU and VAAPI in Mesa on Linux. VCE also has some initial support for encode via VAAPI, but should be considered experimental. 199 189 200 For windows there have been port [https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=4231 attempts] but nothing officialyet.190 For Windows there are port [https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=4231 attempts], but nothing official has been released yet. 201 191 202 192 == External resources ==
