dqed19166
2013-07-05 19:40
浏览 12
已采纳

Golang + Avconv错误(退出状态254)

I'm getting "panic: exit status 254" on the second line.

Can you spot the mistake I made here:

command := exec.Command("avprobe", "inputfile.mp4 -loglevel quiet -show_streams -frame_size -print_format -show_format -of json")

output, err := command.StdoutPipe();
if err != nil {
    log.Panic(err)
}

if err := command.Run(); err != nil {
    log.Panic(err)
}

json.NewDecoder(output).Decode(&struct1)
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanhanzi8328 2013-07-05 20:55
    已采纳

    Package exec

    func Command

    func Command(name string, arg ...string) *Cmd
    

    For example,

    arg := []string{
        "inputfile.mp4",
        "-loglevel", "quiet",
        "-show_streams",
        "-frame_size",
        "-print_format",
        "-show_format",
        "-of", "json",
    }
    command := exec.Command("avprobe", arg...)
    
    打赏 评论
  • dqt20140129 2013-07-05 20:54

    You are running the equivalent of

    avprobe "inputfile.mp4 -loglevel quiet -show_streams -frame_size -print_format -show_format -of json"
    

    I am guessing avprobe doesn't like that, try

    command := exec.Command("avprobe", "inputfile.mp4", "-loglevel", ...)
    

    You can also use exec.CombinedOutput() to get the output from avprobe and see what it says.

    打赏 评论

相关推荐 更多相似问题