ytva/ffmpeg.go
2024-12-31 14:33:46 -07:00

29 lines
841 B
Go

package main
import (
ffmpeg "github.com/u2takey/ffmpeg-go"
)
func mergeStreams(path1 string, path2 string, output string) (err error) {
input := []*ffmpeg.Stream{ffmpeg.Input(path1), ffmpeg.Input(path2)}
defaultArgs := ffmpeg.KwArgs{"c:v": "copy", "c:a": "copy", "format": "matroska"}
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()
}