Codecs & Hardware AccelerationHardware accelerated encoding was first supported in Owncast 0.0.7.
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
ffmpegthat 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.
If you have Intel integrated graphics you may be able to use it using VA-API.
If you have a recent Raspberry Pi and using the Raspberry Pi OS operating system it’s actually quite easy to get Owncast running in a hardware accelerated fashion. Raspberry Pi OS includes support for OpenMax (OMX) out of the box and includes a version of
ffmpeg that is built to support it.
However, this seems to only be true for 32 bit operating systems on a Raspberry Pi, as omx seems to be deprecated under 64 bit environments.
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.
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.
OpenMAX is a unified abstraction layer that allows access to hardware that otherwise requires vendor specific APIs. It will work out of the box on modern Raspberry Pi’s running a recent version of the Raspberry Pi OS operating system.
Verify your copy of ffmpeg has omx support by looking at the ffmpeg instructions below. If
h264_omx is in the list you should be good to go.
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.
- Tal.org instructions on building ffmpeg with nvenc
- Shell script that claims to automate the process on Ubuntu
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.