添加歌曲封面接口
All checks were successful
Go CI / test-and-build (push) Successful in 12s

This commit is contained in:
2026-04-06 23:16:34 +08:00
parent 3182b29932
commit 0b7cd05486
5 changed files with 63 additions and 1 deletions

20
internal/util/ffmpeg.go Normal file
View File

@@ -0,0 +1,20 @@
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
}