From a7b7fa5360b9bfe83ea2f7b3dfc91d5422ff35a1 Mon Sep 17 00:00:00 2001 From: MB-Finski <64466176+MB-Finski@users.noreply.github.com> Date: Tue, 29 Nov 2022 23:03:35 +0200 Subject: [PATCH] Add "format" back into NVENC transcode profile --- stream.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/stream.go b/stream.go index 2c85ee32..ac1b9323 100644 --- a/stream.go +++ b/stream.go @@ -315,6 +315,7 @@ func (s *Stream) transcode(startId int) { scale = fmt.Sprintf("scale_vaapi=w=%d:h=%d:force_original_aspect_ratio=decrease", s.width, s.height) } else if CV == "h264_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) } else { // x264 @@ -331,7 +332,7 @@ func (s *Stream) transcode(startId int) { if CV == "h264_nvenc" { // Due to a bug(?) in NVENC, passthrough=0 must be set args = append(args, []string{ - "-vf", "scale_cuda=passthrough=0", + "-vf", fmt.Sprintf("%s,%s", format, "scale_cuda=passthrough=0"), }...) } else { args = append(args, []string{ @@ -339,17 +340,8 @@ func (s *Stream) transcode(startId int) { }...) } } else { - if CV == "h264_nvenc" { - args = append(args, []string{ - "-vf", scale, - }...) - } else { - args = append(args, []string{ - "-vf", fmt.Sprintf("%s,%s", format, scale), - }...) - } - // Common arguments - args = append(args, []string{ + args = append(args, []string{ + "-vf", fmt.Sprintf("%s,%s", format, scale), "-maxrate", fmt.Sprintf("%d", s.bitrate), "-bufsize", fmt.Sprintf("%d", s.bitrate*2), }...)