英文:
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...)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论