Files
convert/ffprobe.go
T

37 lines
603 B
Go

package main
import (
"encoding/json"
"os/exec"
)
type ffprobeOutput struct {
Streams []struct {
CodecType string `json:"codec_type"`
} `json:"streams"`
}
func ffprobe(inputFile string) (*ffprobeOutput, error) {
var err error
var out ffprobeOutput
args := []string{
"-v", "quiet",
"-print_format", "json",
"-show_streams",
inputFile,
}
proc := exec.Command("ffprobe", args...)
stdout, err := proc.Output()
if err != nil {
return nil, err
}
// fmt.Println("read", string(stdout))
err = json.Unmarshal(stdout, &out)
if err != nil {
return nil, err
}
return &out, nil
}