[]string -> ...string

This commit is contained in:
Carl Pearson
2024-10-04 05:30:45 -06:00
parent e5b76f7b0a
commit 303262efe1
2 changed files with 10 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ type FFProbeOutput struct {
}
// runs ffprobe with the provided args and returns (stdout, stderr, error)
func runFfprobe(args []string) ([]byte, []byte, error) {
func runFfprobe(args ...string) ([]byte, []byte, error) {
ffprobe := "ffprobe"
log.Infoln(ffprobe, strings.Join(args, " "))
cmd := exec.Command(ffprobe, args...)
@@ -35,7 +35,7 @@ func runFfprobe(args []string) ([]byte, []byte, error) {
}
func getAudioFormat(filename string) (string, error) {
output, _, err := runFfprobe([]string{"-v", "quiet", "-print_format", "json", "-show_streams", filename})
output, _, err := runFfprobe("-v", "quiet", "-print_format", "json", "-show_streams", filename)
if err != nil {
log.Errorln("ffprobe error:", err)
return "", err
@@ -65,7 +65,7 @@ func getStreamBitrate(path string, stream int) (uint, error) {
"-of", "default=noprint_wrappers=1:nokey=1",
path}
stdout, _, err := runFfprobe(ffprobeArgs)
stdout, _, err := runFfprobe(ffprobeArgs...)
if err != nil {
fmt.Println("ffprobe error:", err, string(stdout))
return 0, err
@@ -87,7 +87,7 @@ func getFormatBitrate(path string) (uint, error) {
"-of", "default=noprint_wrappers=1:nokey=1",
path}
stdout, _, err := runFfprobe(ffprobeArgs)
stdout, _, err := runFfprobe(ffprobeArgs...)
if err != nil {
fmt.Println("ffprobe error:", err, string(stdout))
return 0, err

View File

@@ -255,9 +255,9 @@ func getLength(path string) (float64, error) {
func getVideoWidth(path string) (uint, error) {
stdout, _, err := runFfprobe([]string{"-v", "error", "-select_streams",
stdout, _, err := runFfprobe("-v", "error", "-select_streams",
"v:0", "-count_packets", "-show_entries",
"stream=width", "-of", "csv=p=0", path})
"stream=width", "-of", "csv=p=0", path)
if err != nil {
log.Errorln("ffprobe error", err)
@@ -293,9 +293,9 @@ func getVideoHeight(path string) (uint, error) {
func getVideoFPS(path string) (float64, error) {
stdout, _, err := runFfprobe([]string{"-v", "error", "-select_streams",
stdout, _, err := runFfprobe("-v", "error", "-select_streams",
"v:0", "-count_packets", "-show_entries",
"stream=r_frame_rate", "-of", "csv=p=0", path})
"stream=r_frame_rate", "-of", "csv=p=0", path)
if err != nil {
log.Errorln("ffprobe error:", err)
return -1, err
@@ -406,11 +406,10 @@ func getVideoMeta(path string) (VideoMeta, error) {
func getAudioDuration(path string) (float64, error) {
stdout, _, err := runFfprobe([]string{
"-v", "error",
stdout, _, err := runFfprobe("-v", "error",
"-show_entries", "format=duration",
"-of", "default=noprint_wrappers=1:nokey=1",
path})
path)
if err != nil {
log.Errorln("ffprobe error:", err)
return 0, err