https://trac.ffmpeg.org/wiki/HWAccelIntro

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).

很多平台都提供了专用于视频处理的硬件,并提供了专门使用这些硬件能力的途径。使用这类硬件能够以更快的速度或者更少的系统资源(主要是更少的CPU资源)完成编解码、过滤等操作,但可能结果会和软件结果不一样或者质量稍差些,此外还可能存在和软件相比更严格的限制。在PC平台上,视频硬件通常被集成在GPU内,而在移动SoC平台上,则通常是一个独立的芯片上(存在许多不同的厂商提供不同的硬件)。

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.

hardware decoder生成和software decoder同等的输出,但消耗的CPU和电量更低。hardware decoder不会实现所有的codec feature。一般hardware decoder可以将输出直接生成在hardware surface中 - 这个特性对于播放而言很有用,因为播放的场景不需要对输出做进一步的处理,当encoder支持hardware surface作为输入时这个特性对于encoder而言也有用。

API支持情况

截屏2020-10-04 上午11.13.00.png
上图是ffmpeg在不同的平台上对不同平台提供的硬件加速视频编解码方案的支持情况,Y表示支持,N表示无法支持,P表示部分支持(部分设备支持或者部分能力支持)。

其中:

  • Direct3D 11 / MediaFoundation 是Windows平台的方案
  • MediaCodec是Android平台的方案
  • VideoToolbox是Mac平台的方案
  • 其他都是行业标准或者硬件厂商自己提出的方案