Add format to max stream

monorepo
Varun Patil 2022-11-22 09:58:41 -08:00
parent c90483f61a
commit 56767bc56d
1 changed files with 17 additions and 6 deletions

View File

@ -304,18 +304,29 @@ func (s *Stream) transcode(startId int) {
// Scaling for output // Scaling for output
var scale string var scale string
var format string
if CV == "h264_vaapi" { if CV == "h264_vaapi" {
scale = fmt.Sprintf("format=nv12|vaapi,hwupload,scale_vaapi=w=%d:h=%d:force_original_aspect_ratio=decrease", s.width, s.height) // VAAPI
} else if s.width >= s.height { format = "format=nv12|vaapi,hwupload"
scale = fmt.Sprintf("format=nv12,scale=-2:%d", s.height) scale = fmt.Sprintf("scale_vaapi=w=%d:h=%d:force_original_aspect_ratio=decrease", s.width, s.height)
} else { } else {
scale = fmt.Sprintf("format=nv12,scale=%d:-2", s.width) // x264
format = "format=nv12"
if s.width >= s.height {
scale = fmt.Sprintf("scale=-2:%d", s.height)
} else {
scale = fmt.Sprintf("scale=%d:-2", s.width)
}
} }
// do not scale or set bitrate for full quality // do not scale or set bitrate for full quality
if s.quality != "max" { if s.quality == "max" {
args = append(args, []string{ args = append(args, []string{
"-vf", scale, "-vf", format,
}...)
} else {
args = append(args, []string{
"-vf", fmt.Sprintf("%s,%s", format, scale),
"-maxrate", fmt.Sprintf("%d", s.bitrate), "-maxrate", fmt.Sprintf("%d", s.bitrate),
"-bufsize", fmt.Sprintf("%d", s.bitrate*2), "-bufsize", fmt.Sprintf("%d", s.bitrate*2),
}...) }...)