Fix ffmpeg/ffprobe downloads (#824)

This commit is contained in:
bnkai
2020-10-03 10:28:02 +03:00
committed by GitHub
parent 30e88b96ee
commit 94dc74f4a8

View File

@@ -39,14 +39,24 @@ func GetPaths(configDirectory string) (string, string) {
} }
func Download(configDirectory string) error { func Download(configDirectory string) error {
url := getFFMPEGURL() for _, url := range getFFMPEGURL() {
err := DownloadSingle(configDirectory, url)
if err != nil {
return err
}
}
return nil
}
func DownloadSingle(configDirectory, url string) error {
if url == "" { if url == "" {
return fmt.Errorf("no ffmpeg url for this platform") return fmt.Errorf("no ffmpeg url for this platform")
} }
// Configure where we want to download the archive // Configure where we want to download the archive
urlExt := path.Ext(url) urlExt := path.Ext(url)
archivePath := filepath.Join(configDirectory, "ffmpeg"+urlExt) urlBase := path.Base(url)
archivePath := filepath.Join(configDirectory, urlBase)
_ = os.Remove(archivePath) // remove archive if it already exists _ = os.Remove(archivePath) // remove archive if it already exists
out, err := os.Create(archivePath) out, err := os.Create(archivePath)
if err != nil { if err != nil {
@@ -99,19 +109,21 @@ func Download(configDirectory string) error {
return nil return nil
} }
func getFFMPEGURL() string { func getFFMPEGURL() []string {
urls := []string{""}
switch runtime.GOOS { switch runtime.GOOS {
case "darwin": case "darwin":
return "https://ffmpeg.zeranoe.com/builds/macos64/static/ffmpeg-4.1-macos64-static.zip" urls = []string{"https://evermeet.cx/ffmpeg/ffmpeg-4.3.1.zip", "https://evermeet.cx/ffmpeg/ffprobe-4.3.1.zip"}
case "linux": case "linux":
// TODO: untar this // TODO: get appropriate arch (arm,arm64,amd64) and xz untar from https://johnvansickle.com/ffmpeg/
//return "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz" // or get the ffmpeg,ffprobe zip repackaged ones from https://ffbinaries.com/downloads
return "" urls = []string{""}
case "windows": case "windows":
return "https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-4.1-win64-static.zip" urls = []string{"https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip"}
default: default:
return "" urls = []string{""}
} }
return urls
} }
func getFFMPEGFilename() string { func getFFMPEGFilename() string {