[]string -> ...string
This commit is contained in:
@@ -16,7 +16,7 @@ type FFProbeOutput struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// runs ffprobe with the provided args and returns (stdout, stderr, error)
|
// 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"
|
ffprobe := "ffprobe"
|
||||||
log.Infoln(ffprobe, strings.Join(args, " "))
|
log.Infoln(ffprobe, strings.Join(args, " "))
|
||||||
cmd := exec.Command(ffprobe, args...)
|
cmd := exec.Command(ffprobe, args...)
|
||||||
@@ -35,7 +35,7 @@ func runFfprobe(args []string) ([]byte, []byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getAudioFormat(filename string) (string, 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 {
|
if err != nil {
|
||||||
log.Errorln("ffprobe error:", err)
|
log.Errorln("ffprobe error:", err)
|
||||||
return "", err
|
return "", err
|
||||||
@@ -65,7 +65,7 @@ func getStreamBitrate(path string, stream int) (uint, error) {
|
|||||||
"-of", "default=noprint_wrappers=1:nokey=1",
|
"-of", "default=noprint_wrappers=1:nokey=1",
|
||||||
path}
|
path}
|
||||||
|
|
||||||
stdout, _, err := runFfprobe(ffprobeArgs)
|
stdout, _, err := runFfprobe(ffprobeArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("ffprobe error:", err, string(stdout))
|
fmt.Println("ffprobe error:", err, string(stdout))
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -87,7 +87,7 @@ func getFormatBitrate(path string) (uint, error) {
|
|||||||
"-of", "default=noprint_wrappers=1:nokey=1",
|
"-of", "default=noprint_wrappers=1:nokey=1",
|
||||||
path}
|
path}
|
||||||
|
|
||||||
stdout, _, err := runFfprobe(ffprobeArgs)
|
stdout, _, err := runFfprobe(ffprobeArgs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("ffprobe error:", err, string(stdout))
|
fmt.Println("ffprobe error:", err, string(stdout))
|
||||||
return 0, err
|
return 0, err
|
||||||
|
13
handlers.go
13
handlers.go
@@ -255,9 +255,9 @@ func getLength(path string) (float64, error) {
|
|||||||
|
|
||||||
func getVideoWidth(path string) (uint, 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",
|
"v:0", "-count_packets", "-show_entries",
|
||||||
"stream=width", "-of", "csv=p=0", path})
|
"stream=width", "-of", "csv=p=0", path)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("ffprobe error", err)
|
log.Errorln("ffprobe error", err)
|
||||||
@@ -293,9 +293,9 @@ func getVideoHeight(path string) (uint, error) {
|
|||||||
|
|
||||||
func getVideoFPS(path string) (float64, 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",
|
"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 {
|
if err != nil {
|
||||||
log.Errorln("ffprobe error:", err)
|
log.Errorln("ffprobe error:", err)
|
||||||
return -1, err
|
return -1, err
|
||||||
@@ -406,11 +406,10 @@ func getVideoMeta(path string) (VideoMeta, error) {
|
|||||||
|
|
||||||
func getAudioDuration(path string) (float64, error) {
|
func getAudioDuration(path string) (float64, error) {
|
||||||
|
|
||||||
stdout, _, err := runFfprobe([]string{
|
stdout, _, err := runFfprobe("-v", "error",
|
||||||
"-v", "error",
|
|
||||||
"-show_entries", "format=duration",
|
"-show_entries", "format=duration",
|
||||||
"-of", "default=noprint_wrappers=1:nokey=1",
|
"-of", "default=noprint_wrappers=1:nokey=1",
|
||||||
path})
|
path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("ffprobe error:", err)
|
log.Errorln("ffprobe error:", err)
|
||||||
return 0, err
|
return 0, err
|
||||||
|
Reference in New Issue
Block a user