ytva/ffmpeg.go

30 lines
852 B
Go
Raw Normal View History

2024-12-31 16:33:46 -05:00
package main
import (
ffmpeg "github.com/u2takey/ffmpeg-go"
)
2024-12-31 18:59:03 -05:00
func mergeStreams(path1 string, path2 string, format string, output string) (err error) {
2024-12-31 16:33:46 -05:00
input := []*ffmpeg.Stream{ffmpeg.Input(path1), ffmpeg.Input(path2)}
2024-12-31 18:59:03 -05:00
defaultArgs := ffmpeg.KwArgs{"c:v": "copy", "c:a": "copy", "format": format}
2024-12-31 16:33:46 -05:00
var ffmpegLogLevel ffmpeg.KwArgs
var silent bool
if Flags.Verbose {
ffmpegLogLevel = ffmpeg.KwArgs{"v": "info"}
silent = false
} else if Flags.Quiet {
ffmpegLogLevel = ffmpeg.KwArgs{"v": "quiet"}
silent = true
} else {
ffmpegLogLevel = ffmpeg.KwArgs{"v": "error"}
silent = true
}
kwArgs := ffmpeg.MergeKwArgs([]ffmpeg.KwArgs{ffmpegLogLevel, defaultArgs})
return ffmpeg.Output(input, output, kwArgs).OverWriteOutput().ErrorToStdOut().Silent(silent).Run()
}