diff --git a/go_vod/config.go b/go_vod/config.go index 5c6d72ae..9514da68 100644 --- a/go_vod/config.go +++ b/go_vod/config.go @@ -42,6 +42,9 @@ type Config struct { // Number of seconds to wait before shutting down a client ManagerIdleTime int `json:"managerIdleTime"` + // Quality Factor (e.g. CRF / global_quality) + QF int `json:"qf"` + // Hardware acceleration configuration // VA-API diff --git a/go_vod/stream.go b/go_vod/stream.go index 7b6023bb..7a5b51c8 100644 --- a/go_vod/stream.go +++ b/go_vod/stream.go @@ -451,14 +451,6 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string { args = append(args, []string{"-profile:v", "main"}...) } - // Apply bitrate cap if not max quality - if s.quality != QUALITY_MAX { - args = append(args, []string{ - "-maxrate", fmt.Sprintf("%d", s.bitrate), - "-bufsize", fmt.Sprintf("%d", s.bitrate*2), - }...) - } - // Output specs for video args = append(args, []string{ "-map", "0:v:0", @@ -467,7 +459,7 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string { // Device specific output args if CV == ENCODER_VAAPI { - args = append(args, []string{"-global_quality", "25"}...) + args = append(args, []string{"-global_quality", fmt.Sprintf("%d", s.c.QF)}...) if s.c.VAAPILowPower { args = append(args, []string{"-low_power", "1"}...) @@ -478,7 +470,7 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string { "-tune", "ll", "-rc", "vbr", "-rc-lookahead", "30", - "-cq", "24", + "-cq", fmt.Sprintf("%d", s.c.QF), }...) if s.c.NVENCTemporalAQ { @@ -487,7 +479,7 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string { } else if CV == ENCODER_X264 { args = append(args, []string{ "-preset", "faster", - "-crf", "24", + "-crf", fmt.Sprintf("%d", s.c.QF), }...) } diff --git a/main.go b/main.go index 316edb26..f43ad6ad 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( "github.com/pulsejet/go-vod/go_vod" ) -const VERSION = "0.1.20" +const VERSION = "0.1.21" func main() { // Build initial configuration