Add support for NVIDIA GPU accelerated transcoding
Add a transcoding profile for ffmpeg suitable for using with NVENC.monorepo
parent
56767bc56d
commit
9972fc23c6
18
stream.go
18
stream.go
|
@ -288,12 +288,16 @@ func (s *Stream) transcode(startId int) {
|
||||||
// encoder selection
|
// encoder selection
|
||||||
CV := "libx264"
|
CV := "libx264"
|
||||||
|
|
||||||
// no need to transcode h264 streams for max quality
|
// Check whether hwaccel should be used
|
||||||
if os.Getenv("VAAPI") == "1" {
|
if os.Getenv("VAAPI") == "1" {
|
||||||
CV = "h264_vaapi"
|
CV = "h264_vaapi"
|
||||||
extra := "-hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi"
|
extra := "-hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi"
|
||||||
args = append(args, strings.Split(extra, " ")...)
|
args = append(args, strings.Split(extra, " ")...)
|
||||||
}
|
} else if os.Getenv("NVENC") == "1" {
|
||||||
|
CV = "h264_nvenc"
|
||||||
|
extra := "-hwaccel cuda -hwaccel_output_format cuda"
|
||||||
|
args = append(args, strings.Split(extra, " ")...)
|
||||||
|
}
|
||||||
|
|
||||||
// Input specs
|
// Input specs
|
||||||
args = append(args, []string{
|
args = append(args, []string{
|
||||||
|
@ -309,7 +313,15 @@ func (s *Stream) transcode(startId int) {
|
||||||
// VAAPI
|
// VAAPI
|
||||||
format = "format=nv12|vaapi,hwupload"
|
format = "format=nv12|vaapi,hwupload"
|
||||||
scale = fmt.Sprintf("scale_vaapi=w=%d:h=%d:force_original_aspect_ratio=decrease", s.width, s.height)
|
scale = fmt.Sprintf("scale_vaapi=w=%d:h=%d:force_original_aspect_ratio=decrease", s.width, s.height)
|
||||||
} else {
|
} else if CV == "h264_nvenc" {
|
||||||
|
// NVENC
|
||||||
|
format = "format=nv12|cuda,hwupload"
|
||||||
|
if s.width >= s.height {
|
||||||
|
scale = fmt.Sprintf("scale_cuda=-2:%d", s.height)
|
||||||
|
} else {
|
||||||
|
scale = fmt.Sprintf("scale_cuda=%d:-2", s.width)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// x264
|
// x264
|
||||||
format = "format=nv12"
|
format = "format=nv12"
|
||||||
if s.width >= s.height {
|
if s.width >= s.height {
|
||||||
|
|
Loading…
Reference in New Issue