Skip to content

Instantly share code, notes, and snippets.

@bartzz
bartzz / get_video_resolution.go
Created December 19, 2019 09:12
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