ffmpeg-go
ffmpeg-go copied to clipboard
How to obtain the playback duration of MP3 through ffmpeg-go
How to obtain the playback duration of MP3 through ffmpeg-go. thanks
You can get from JSON like (if you want, you can use gjson lib)
func GetDurationFromJson() float32 {
file := "yourfilepath"
out, err := ffmpeg.Probe(file, []ffmpeg.KwArgs{
{"show_entries": "format=duration"},
{"v": "quiet"},
}...)
if err != nil {
log.Fatal(err)
}
var JSONData map[string]interface{}
json.Unmarshal([]byte(out), &JSONData)
return JSONData["format"].(map[string]interface{})["duration"].(float32)
}
It helped me,thk u