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

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条回答 默认 最新

  • drsw9390405 2019-02-19 09:14
    关注

    The reason you aren't getting any clues is that you have set the command to not say anything. From the ffprobe docs

    -loglevel [flags+]loglevel | -v [flags+]loglevel Set logging level and flags used by the library. ....

    loglevel is a string or a number containing one of the following values:

    ‘quiet, -8’ Show nothing at all; be silent.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!