dtpf76658
2019-02-18 21:09
浏览 1.2k
已采纳

exec.Command错误,没有输出到stdout或stderr

I am trying to get the duration of a video using ffprobe and exec.Command but I keep getting an error. However, stdout and stderr are both empty so I don't know what the problem is.

func getVideoLength(filename string) float64 {
cmd := exec.Command("ffprobe", "-i", filename, "-show_entries", "format=duration", "-v", "quiet", "-of", "csv=\"p=0\"")
fmt.Println("ffprobe", "-i", filename, "-show_entries", "format=duration", "-v", "quiet", "-of", "csv=\"p=0\"")
    var out bytes.Buffer
    var stderr bytes.Buffer
    cmd.Stdout = &out
    cmd.Stderr = &stderr
    err := cmd.Run()
    if err != nil {
        fmt.Println("out: " + out.String())
        fmt.Println("stderr: " + stderr.String())
        log.Fatal(err)
    }

    length, err := strconv.ParseFloat(out.String(), 64)
    if err != nil {
        log.Fatal(err)
    }

return length
}

Here is the output I get:

ffprobe -i amelie.mp4 -show_entries format=duration -v quiet -of csv="p=0"
out: 
stderr: 
2019/02/18 21:04:39 exit status 1

not very helpful.

Any ideas?. Thanks.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题