Skip to content

Instantly share code, notes, and snippets.

@bartzz
Created December 19, 2019 09:12
Show Gist options
  • Select an option

  • Save bartzz/cebb9ae021f206a8ad800eff173d995b to your computer and use it in GitHub Desktop.

Select an option

Save bartzz/cebb9ae021f206a8ad800eff173d995b to your computer and use it in GitHub Desktop.
Get video resolution in Go using FFmpeg
// Get width and height resolution string of a video file using FFmpeg
// Returns a string like: "1920x1080"
func GetVideoResolution(path string) (string, err) {
out, err := exec.Command("/usr/bin/ffmpeg", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height", "-of", "csv=s=x:p=0", path).CombinedOutput()
if nil != err {
return "", err
}
return strings.TrimSpace(string(out)), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment