vaapi: make lowpower configurable

monorepo
Varun Patil 2023-03-09 12:39:43 -08:00
parent f41680455c
commit a38fed1983
2 changed files with 13 additions and 10 deletions

View File

@ -26,6 +26,8 @@ type Config struct {
ManagerIdleTime int `json:"managerIdleTime"`
// Hardware acceleration configuration
VAAPI bool `json:"vaapi"`
VAAPI bool `json:"vaapi"`
VAAPILowPower bool `json:"vaapiLowPower"`
NVENC bool `json:"nvenc"`
}

View File

@ -392,11 +392,11 @@ func (s *Stream) transcodeArgs(startAt float64) []string {
// Scaling for output
var scale string
var format string
if CV == "h264_vaapi" {
if s.c.VAAPI {
// VAAPI
format = "format=nv12|vaapi,hwupload"
scale = fmt.Sprintf("scale_vaapi=w=%d:h=%d:force_original_aspect_ratio=decrease", s.width, s.height)
} else if CV == "h264_nvenc" {
} else if s.c.NVENC {
// NVENC
format = "format=nv12|cuda,hwupload"
scale = fmt.Sprintf("scale_cuda=w=%d:h=%d:force_original_aspect_ratio=decrease:passthrough=0", s.width, s.height)
@ -412,7 +412,7 @@ func (s *Stream) transcodeArgs(startAt float64) []string {
// do not scale or set bitrate for full quality
if s.quality == "max" {
if CV == "h264_nvenc" {
if s.c.NVENC {
// Due to a bug(?) in NVENC, passthrough=0 must be set
args = append(args, []string{
"-vf", fmt.Sprintf("%s,%s", format, "scale_cuda=passthrough=0"),
@ -437,12 +437,13 @@ func (s *Stream) transcodeArgs(startAt float64) []string {
}...)
// Device specific output args
if CV == "h264_vaapi" {
args = append(args, []string{
"-low_power", "1",
"-global_quality", "25",
}...)
} else if CV == "h264_nvenc" {
if s.c.VAAPI {
args = append(args, []string{"-global_quality", "25"}...)
if s.c.VAAPILowPower {
args = append(args, []string{"-low_power", "1"}...)
}
} else if s.c.NVENC {
args = append(args, []string{
"-preset", "p6",
"-tune", "ll",