Start work on hardware acceleration.

Documentation first, code later.
pull/21/head
knotteye 2020-11-08 23:12:24 -06:00
parent cccdc8838d
commit 364994decc
3 changed files with 62 additions and 6 deletions

View File

@ -38,17 +38,16 @@ transcode:
# satyr will generate one source quality variant, and the remaining
# variants will be of incrementally lower quality and bitrate
# having more than 4-5 variants will start giving diminishing returns on stream quality for cpu load
# if you can't afford to generate at least 3 variants, it's recommended to leave adaptive streaming off
inputflags: ""
# additional flags to apply to the input during transcoding
outputflags: ""
# additional flags to apply to the output during transcoding
# hardware acceleration is a bit difficult to configure programmatically
# this is a good place to do so for your system
# https://trac.ffmpeg.org/wiki/HWAccelIntro is a good place to start
# having more than 4-5 variants will start giving diminishing returns on stream quality for cpu load
# if you can't afford to generate at least 3 variants, it's recommended to leave adaptive streaming off
hwaccel:
# See HWACCEL.md for information on configuring hardware acceleration.
crypto:
saltRounds: 12

53
docs/HWACCEL.md Normal file
View File

@ -0,0 +1,53 @@
## Configuration Hardware Acceleration
Satyr supports the NVENC and VA-API hardware acceleration APIs. If you've configured your system correctly (the hard part) it should be enough to set the type and use the default device setting if you only have one hardware acceleration device.
### System
Configuring the system for any hardware acceleration API involves three main steps: selecting the right drivers, installing the API libraries, and configuring ffmpeg.
#### NVENC
NVENC in ffmpeg can work with either open-source drivers (nouvea) or nvidia's proprietary drivers. The documentation for your distribution should have instructions for installing these.
The only system library you should need is the CUDA toolkit, general named cudatoolkit, nvidia-cuda-toolkit, or some variation in your system repositories.
You can also try installing manually from [here](https://developer.nvidia.com/cuda-downloads).
Most binary distributions provide a version of ffmpeg with NVENC already enabled. If not you can try compiling ffmpeg from source with the `--enable-nvenc` flag. If you use a source based distribution you should be familiar with enabling optional compile flags.
You can verify that ffmpeg has been set up correctly by checking the output of `ffmpeg -hide_banner -hwaccels | grep cuvid` and `ffmpeg -hide_banner -encoders | grep nvenc`. If you don't see anything, something is wrong.
#### VA-API
VA-API is an extremely generic API. Although the package names might be different in your distribution, the arch wiki page for hardware acceleration has good information on [driver selection](https://wiki.archlinux.org/index.php/Hardware_video_acceleration#Installation) and [verifying](https://wiki.archlinux.org/index.php/Hardware_video_acceleration#Verifying_VA-API) a VA-API install for a wide range of devices.
Regardless of driver selection, you will also need libva or the equivalent from your distrubtion, and libva-utils can be helpful as well.
Most binary distributions provide a version of ffmpeg with VA-API already enabled. If not you can try compiling ffmpeg from source with the `--enable-vaapi` flag. If you use a source based distribution you should be familiar with enabling optional compile flags.
You can verify that ffmpeg has been set up correctly by checking the output of `ffmpeg -hide_banner -hwaccels | grep vaapi` and `ffmpeg -hide_banner -encoders | grep vaapi`. If you don't see anything, something is wrong.
### Satyr
```
# Decoding
hwaccel:
# Enable hardware acceleration for decoding as well as encoding.
# Probably not worth it, hardware decoding won't be any faster compared to software on a vaguely modern CPU
# Hardware decoding also may not support the input format, in which case transcoding will fail
decode: true
# Only supported for VA-API
# Fall back to software decoding if hardware decoding fails
hwaccel:
decode: 'fallback'
# NVENC
hwaccel:
type: 'nvenc'
# device is optional for nvenc
device: 0
# nvenc wants a device number instead of a path, set to null to disable
# VA-API
hwaccel:
type: 'vaapi'
# device is mandatory for va-api
device: '/dev/dri/renderD128'
```

View File

@ -32,6 +32,10 @@ transcode:
#unused right now, will always transcode to dash
format: dash
hwaccel:
# see docs/HWACCEL.md for instructions on configuring hardware acceleration
type: null
chat:
irc: