Skip to content

Commit

Permalink
feat(shorts): ignore resolution definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikvedvik committed Nov 17, 2023
1 parent d36ba68 commit a840d11
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions services/transcode/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit a840d11

Please sign in to comment.