Question

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)
Was it helpful?

Solution 2

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top