package util import ( "os/exec" "strconv" ) func ExtractCover(filePath string, id int) bool { if _, err := exec.LookPath("ffmpeg"); err != nil { return false } coverPath := "cache/cover/" + strconv.Itoa(id) + ".jpg" cmd := exec.Command("ffmpeg", "-i", filePath, "-an", "-vcodec", "mjpeg", "-q:v", "5", "-f", "image2", "-y", coverPath) if err := cmd.Run(); err != nil { return false } return true }