Codecs & Hardware Acceleration
Hardware accelerated encoding was first supported in Owncast 0.0.7.Requirements
All four of these things need to be true to support hardware accelerated encoding with Owncast.
- You are not running on a VPS provided to you by a hosting provider, as shared virtual servers do not allow for direct access to hardware.
- You have compatible hardware and have direct access to it.
- You installed and configured any drivers and libraries needed to take advantage of your hardware.
- You have a copy of
ffmpeg
that is version 4.1.5 or greater that is specifically built to utilize these drivers and libraries.
Things to keep in mind
- Most people won’t be able to take advantage of this unless you’re running your own hardware.
- Just because a specific hardware accelerated codec shows in the Owncast admin does not mean your machine is configured to support it. It simply means Owncast believes that codec to be available.
- Very little of what is required to get your hardware working has anything to do with Owncast. Any questions you have about your particular hardware should be directed to your hardware manufacturer or whoever provides the drivers and libraries to utilize it. There’s likely a lot of information already online, so please do your research.
Compatible hardware
Intel Graphics
If you have Intel integrated graphics you may be able to use it using VA-API.
NVIDIA GPUs
NVIDIA GPUs ship with an on-chip hardware encoder unit often referred to as NVENC. Separate from the CUDA cores, NVENC run encoding workloads without slowing the execution of graphics or CUDA workloads running at the same time.
As of July 2019 Kepler, Maxwell, Pascal, Volta and Turing generation GPUs support hardware encoding. Visit the NVIDIA GPU Support Matrix to verify your GPU is listed in the “encoder” list.
AMD GPUs
VA-API is supported on AMD and ATI GPUs by the libva-mesa-driver.
Note: ffmpeg 5 is not currently supported with VA-API. Please use a version less than 5. Read the issue about this particular issue to learn more.
Compatible codecs/libraries
VA-API
VA-API (video acceleration API) is a layer to support hardware accelerated encoding on linux. You need the libva
library installed for it to work. VA-API is not compatible with ARM chipsets.
Note: ffmpeg 5 is not currently supported with VA-API. Please use a version less than 5. Read the issue about this particular issue to learn more.
Links:
NVIDIA Encoder (nvenc)
Follow the instructions on the NVIDIA ffmpeg transcoding guide to install all the required drivers and libraries. This requires installing a driver from the NVIDIA website, Downloading and install the CUDA toolkit, downloading nv-codec-headers, and building ffmpeg. Scroll to the section entitled Hardware accelerated transcoding with FFmpeg at the NVIDIA transcoding guide for more information.
You may be able to find a pre-built version of ffmpeg that has nvenc
support, however that’s outside the scope of this document. You still need NVIDIA drivers regardless.
Links:
- Tal.org instructions on building ffmpeg with nvenc
- Shell script that claims to automate the process on Ubuntu
ffmpeg
Once your system is configured to use the correct drivers and libraries required you’ll need to make sure your copy of ffmpeg
supports it.
Verify you have ffmpeg installed that’s at least version 4.1.5.
$ ffmpeg -version
ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
Verify the codec you expect to use is enabled in your version of ffmpeg.
$ ffmpeg -hide_banner -codecs | grep 264
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_mmal ) (encoders: libx264 libx264rgb h264_omx h264_v4l2m2m h264_vaapi )
If the codec you hope to use is not in this list then you may need to build your own copy of ffmpeg that supports it.