From a840d11b4711772031bb3ab06703607981121cf2 Mon Sep 17 00:00:00 2001 From: Fredrik Vedvik Date: Fri, 17 Nov 2023 13:56:31 +0100 Subject: [PATCH] feat(shorts): ignore resolution definition --- services/transcode/video.go | 44 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/services/transcode/video.go b/services/transcode/video.go index 8e7e6d9c..1dadf418 100644 --- a/services/transcode/video.go +++ b/services/transcode/video.go @@ -2,11 +2,12 @@ package transcode import ( "fmt" + "os" + "path/filepath" + "github.com/bcc-code/bccm-flows/common" "github.com/bcc-code/bccm-flows/paths" "github.com/bcc-code/bccm-flows/services/ffmpeg" - "os" - "path/filepath" ) func VideoH264(input common.VideoInput, cb ffmpeg.ProgressCallback) (*common.VideoResult, error) { @@ -42,30 +43,6 @@ func VideoH264(input common.VideoInput, cb ffmpeg.ProgressCallback) (*common.Vid ) } - //params = append(params, - // "-maxrate", input.Bitrate, - //) - // - //if input.BufferSize != "" { - // params = append(params, - // "-bufsize", input.BufferSize, - // ) - //} - - var filterComplex string - - filterComplex += fmt.Sprintf("[0:0] scale=%[1]d:%[2]d:force_original_aspect_ratio=decrease,pad=%[1]d:%[2]d:(ow-iw)/2:(oh-ih)/2 [main];", - 1920, - 1080) - - if input.WatermarkPath != nil { - filterComplex += "[main][1:0] overlay=main_w-overlay_w:0 [main];" - } - - filterComplex += fmt.Sprintf("[main] scale=%[1]d:%[2]d:force_original_aspect_ratio=decrease [out]", - input.Width, - input.Height) - info, err := ffmpeg.GetStreamInfo(input.Path.Local()) if err != nil { return nil, err @@ -80,10 +57,21 @@ func VideoH264(input common.VideoInput, cb ffmpeg.ProgressCallback) (*common.Vid } } + var filterComplex string + + if input.WatermarkPath != nil { + filterComplex += "[0:0][1:0]overlay=main_w-overlay_w:0[out]" + } + + if filterComplex != "" { + params = append(params, + "-filter_complex", filterComplex, + "-map", "[out]", + ) + } + params = append(params, "-r", fmt.Sprintf("%d", framerate), - "-filter_complex", filterComplex, - "-map", "[out]", ) filename := input.Path.Base()