From 56767bc56d246dd0816713aa1af0ac4dd8f0080a Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 22 Nov 2022 09:58:41 -0800 Subject: [PATCH] Add format to max stream --- stream.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/stream.go b/stream.go index 08c5c163..06b1633e 100644 --- a/stream.go +++ b/stream.go @@ -304,18 +304,29 @@ func (s *Stream) transcode(startId int) { // Scaling for output var scale string + var format string 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) - } else if s.width >= s.height { - scale = fmt.Sprintf("format=nv12,scale=-2:%d", s.height) + // 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 { - 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 - if s.quality != "max" { + if s.quality == "max" { 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), "-bufsize", fmt.Sprintf("%d", s.bitrate*2), }...)