stream: make QF configurable

monorepo
Varun Patil 2023-10-24 17:17:36 -07:00
parent 27d332eff5
commit 2438a2946d
3 changed files with 7 additions and 12 deletions

View File

@ -42,6 +42,9 @@ type Config struct {
// Number of seconds to wait before shutting down a client // Number of seconds to wait before shutting down a client
ManagerIdleTime int `json:"managerIdleTime"` ManagerIdleTime int `json:"managerIdleTime"`
// Quality Factor (e.g. CRF / global_quality)
QF int `json:"qf"`
// Hardware acceleration configuration // Hardware acceleration configuration
// VA-API // VA-API

View File

@ -451,14 +451,6 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string {
args = append(args, []string{"-profile:v", "main"}...) 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 // Output specs for video
args = append(args, []string{ args = append(args, []string{
"-map", "0:v:0", "-map", "0:v:0",
@ -467,7 +459,7 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string {
// Device specific output args // Device specific output args
if CV == ENCODER_VAAPI { 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 { if s.c.VAAPILowPower {
args = append(args, []string{"-low_power", "1"}...) args = append(args, []string{"-low_power", "1"}...)
@ -478,7 +470,7 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string {
"-tune", "ll", "-tune", "ll",
"-rc", "vbr", "-rc", "vbr",
"-rc-lookahead", "30", "-rc-lookahead", "30",
"-cq", "24", "-cq", fmt.Sprintf("%d", s.c.QF),
}...) }...)
if s.c.NVENCTemporalAQ { if s.c.NVENCTemporalAQ {
@ -487,7 +479,7 @@ func (s *Stream) transcodeArgs(startAt float64, isHls bool) []string {
} else if CV == ENCODER_X264 { } else if CV == ENCODER_X264 {
args = append(args, []string{ args = append(args, []string{
"-preset", "faster", "-preset", "faster",
"-crf", "24", "-crf", fmt.Sprintf("%d", s.c.QF),
}...) }...)
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/pulsejet/go-vod/go_vod" "github.com/pulsejet/go-vod/go_vod"
) )
const VERSION = "0.1.20" const VERSION = "0.1.21"
func main() { func main() {
// Build initial configuration // Build initial configuration