package deps import ( "fmt" "os" "path/filepath" "runtime" ) // Official Bento4 SDK binaries from bento4.com (v1.6.0-641). // linux/arm64 and windows/arm64 are not published there — clear error. func fetchMP4Decrypt(binDir string, logf func(string, ...any)) (string, error) { url, archiveName, err := bento4URL() if err != nil { return "", err } archivePath := filepath.Join(binDir, archiveName) if err := downloadTo(url, archivePath, logf); err != nil { return "", err } defer func() { _ = os.Remove(archivePath) }() want := "mp4decrypt" if runtime.GOOS == "windows" { want = "mp4decrypt.exe" } dest := filepath.Join(binDir, want) if err := extractNamed(archivePath, binDir, want, dest); err != nil { return "", err } chmodX(dest) return dest, nil } func bento4URL() (url, archiveName string, err error) { const base = "https://www.bok.net/Bento4/binaries/" switch runtime.GOOS + "/" + runtime.GOARCH { case "windows/amd64": name := "Bento4-SDK-1-6-0-641.x86_64-microsoft-win32.zip" return base + name, name, nil case "linux/amd64": name := "Bento4-SDK-1-6-0-641.x86_64-unknown-linux.zip" return base + name, name, nil case "darwin/amd64", "darwin/arm64": name := "Bento4-SDK-1-6-0-641.universal-apple-macosx.zip" return base + name, name, nil default: return "", "", fmt.Errorf("no Bento4 binary for %s/%s (place mp4decrypt in bin/ manually)", runtime.GOOS, runtime.GOARCH) } }