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

huangapple go评论81阅读模式
英文:

Golang + Avconv error (exit status 254)

问题

我在第二行遇到了"panic: exit status 254"的错误。

你能发现我在这里犯了什么错误吗:

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)
英文:

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)

答案1

得分: 1

你正在运行等效的命令:

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

我猜avprobe不喜欢这样,试试这个:

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

你也可以使用exec.CombinedOutput()来获取avprobe的输出并查看它说了什么。

英文:

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.

答案2

得分: 0

> 包 exec
>
> func Command
>
> func Command(name string, arg ...string) *Cmd

例如,

arg := []string{
	"inputfile.mp4",
	"-loglevel", "quiet",
	"-show_streams",
	"-frame_size",
	"-print_format",
	"-show_format",
	"-of", "json",
}
command := exec.Command("avprobe", arg...)
英文:

> 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...)

huangapple
  • 本文由 发表于 2013年7月6日 03:40:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/17495862.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定