- streamd: MPD-only start, proxy field, ffmpeg/NRE/mp4decrypt auto-install - GET/PUT /api/modules for module.yaml sync; agent sync_modules - RTE Live-tab AutoPlay fixes; modules zip named bbc/rte/tg4.zip - Telegram notify scripts wired into Forgejo release workflows
64 lines
2 KiB
Go
64 lines
2 KiB
Go
package deps
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
// BtbN static GPL builds (linked from ffmpeg.org). No official BtbN macOS
|
|
// builds — on darwin we leave a clear note to use Homebrew.
|
|
func fetchFFmpeg(binDir string, logf func(string, ...any)) (string, error) {
|
|
url, archiveName, err := ffmpegURL()
|
|
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 := "ffmpeg"
|
|
if runtime.GOOS == "windows" {
|
|
want = "ffmpeg.exe"
|
|
}
|
|
dest := filepath.Join(binDir, want)
|
|
if err := extractNamed(archivePath, binDir, want, dest); err != nil {
|
|
return "", err
|
|
}
|
|
chmodX(dest)
|
|
|
|
// Best-effort ffprobe alongside ffmpeg.
|
|
probeWant := "ffprobe"
|
|
if runtime.GOOS == "windows" {
|
|
probeWant = "ffprobe.exe"
|
|
}
|
|
probeDest := filepath.Join(binDir, probeWant)
|
|
_ = extractNamed(archivePath, binDir, probeWant, probeDest)
|
|
chmodX(probeDest)
|
|
|
|
return dest, nil
|
|
}
|
|
|
|
func ffmpegURL() (url, archiveName string, err error) {
|
|
switch runtime.GOOS + "/" + runtime.GOARCH {
|
|
case "windows/amd64":
|
|
return "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip",
|
|
"ffmpeg-win64-gpl.zip", nil
|
|
case "windows/arm64":
|
|
return "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-winarm64-gpl.zip",
|
|
"ffmpeg-winarm64-gpl.zip", nil
|
|
case "linux/amd64":
|
|
return "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz",
|
|
"ffmpeg-linux64-gpl.tar.xz", nil
|
|
case "linux/arm64":
|
|
return "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz",
|
|
"ffmpeg-linuxarm64-gpl.tar.xz", nil
|
|
case "darwin/amd64", "darwin/arm64":
|
|
return "", "", fmt.Errorf("no static ffmpeg auto-build for macOS; install with: brew install ffmpeg")
|
|
default:
|
|
return "", "", fmt.Errorf("unsupported platform %s/%s for ffmpeg auto-download", runtime.GOOS, runtime.GOARCH)
|
|
}
|
|
}
|