From 303262efe1513fb03a60c403f81cb8817b3148b6 Mon Sep 17 00:00:00 2001 From: Carl Pearson Date: Fri, 4 Oct 2024 05:30:45 -0600 Subject: [PATCH] []string -> ...string --- ffprobe.go | 8 ++++---- handlers.go | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ffprobe.go b/ffprobe.go index 17e8139..d4e4321 100644 --- a/ffprobe.go +++ b/ffprobe.go @@ -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 diff --git a/handlers.go b/handlers.go index 6bf1779..11ab136 100644 --- a/handlers.go +++ b/handlers.go @@ -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