diff --git a/README.md b/README.md index ed0d665..5a7e3f6 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ services: ##### Binary 1. Download a binary release from GitHub, or clone the repository and compile on your machine (e.g. with `GOOS=linux GOARCH=amd64 go build -o plex-dvr-hls-linux-amd64 cmd/main.go`) 2. Create a `config.json` in the working directory and fill in the necessary. - - Possible values for `encoder_profile` are `vaapi`, `video_toolbox`, `omx` and `cpu`. A sample `config.example.json` is available on GitHub. + - Possible values for `encoder_profile` are `vaapi`, `video_toolbox`, `omx`, `nvenc` and `cpu`. A sample `config.example.json` is available on GitHub. + - `nvenc` requires an NVIDIA GPU and ffmpeg with NVENC support. For Docker, see [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html). 3. Create a `channels.json` and fill in the necessary. - A sample `channels.example.json` is available on GitHub. 4. Copy the `templates` folder from this repository into the working directory (alongside the two JSON files) diff --git a/config/config.go b/config/config.go index c576e88..f75624b 100644 --- a/config/config.go +++ b/config/config.go @@ -13,6 +13,7 @@ const ( EncoderProfileVAAPI EncoderProfile = "vaapi" EncoderProfileVideoToolbox EncoderProfile = "video_toolbox" EncoderProfileOMX EncoderProfile = "omx" + EncoderProfileNVENC EncoderProfile = "nvenc" ) type Config struct { @@ -33,6 +34,8 @@ func (c Config) GetEncoderProfile() EncoderProfile { return EncoderProfileOMX case EncoderProfileVideoToolbox: return EncoderProfileVideoToolbox + case EncoderProfileNVENC: + return EncoderProfileNVENC } return EncoderProfileCPU diff --git a/routes/stream.go b/routes/stream.go index 6d35fce..f790eb2 100644 --- a/routes/stream.go +++ b/routes/stream.go @@ -72,6 +72,14 @@ func Stream(c *gin.Context) { "-hwaccel", "videotoolbox", ) + case config.EncoderProfileNVENC: + ffmpegArgs = append( + ffmpegArgs, + "-hwaccel", + "cuda", + "-hwaccel_output_format", + "cuda", + ) } ffmpegArgs = append( @@ -111,6 +119,15 @@ func Stream(c *gin.Context) { "h264_omx", ) break + case config.EncoderProfileNVENC: + ffmpegArgs = append( + ffmpegArgs, + "-c:v", + "h264_nvenc", + "-preset", + "p3", + ) + break default: ffmpegArgs = append( ffmpegArgs,