Skip to content

Commit a64ca7f

Browse files
authored
feat: Add support for NVENC encoder profile (PR: #48)
1 parent 8c213aa commit a64ca7f

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ services:
4141
##### Binary
4242
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`)
4343
2. Create a `config.json` in the working directory and fill in the necessary.
44-
- Possible values for `encoder_profile` are `vaapi`, `video_toolbox`, `omx` and `cpu`. A sample `config.example.json` is available on GitHub.
44+
- Possible values for `encoder_profile` are `vaapi`, `video_toolbox`, `omx`, `nvenc` and `cpu`. A sample `config.example.json` is available on GitHub.
45+
- `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).
4546
3. Create a `channels.json` and fill in the necessary.
4647
- A sample `channels.example.json` is available on GitHub.
4748
4. Copy the `templates` folder from this repository into the working directory (alongside the two JSON files)

config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const (
1313
EncoderProfileVAAPI EncoderProfile = "vaapi"
1414
EncoderProfileVideoToolbox EncoderProfile = "video_toolbox"
1515
EncoderProfileOMX EncoderProfile = "omx"
16+
EncoderProfileNVENC EncoderProfile = "nvenc"
1617
)
1718

1819
type Config struct {
@@ -33,6 +34,8 @@ func (c Config) GetEncoderProfile() EncoderProfile {
3334
return EncoderProfileOMX
3435
case EncoderProfileVideoToolbox:
3536
return EncoderProfileVideoToolbox
37+
case EncoderProfileNVENC:
38+
return EncoderProfileNVENC
3639
}
3740

3841
return EncoderProfileCPU

routes/stream.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ func Stream(c *gin.Context) {
7272
"-hwaccel",
7373
"videotoolbox",
7474
)
75+
case config.EncoderProfileNVENC:
76+
ffmpegArgs = append(
77+
ffmpegArgs,
78+
"-hwaccel",
79+
"cuda",
80+
"-hwaccel_output_format",
81+
"cuda",
82+
)
7583
}
7684

7785
ffmpegArgs = append(
@@ -111,6 +119,15 @@ func Stream(c *gin.Context) {
111119
"h264_omx",
112120
)
113121
break
122+
case config.EncoderProfileNVENC:
123+
ffmpegArgs = append(
124+
ffmpegArgs,
125+
"-c:v",
126+
"h264_nvenc",
127+
"-preset",
128+
"p3",
129+
)
130+
break
114131
default:
115132
ffmpegArgs = append(
116133
ffmpegArgs,

0 commit comments

Comments
 (0)