Files

40 lines
1.7 KiB
PowerShell
Raw Permalink Normal View History

2026-09-09 10:21:29 +02:00
param(
[string]$Destination = "$PSScriptRoot\..\src-tauri\binaries\ffmpeg-x86_64-pc-windows-msvc.exe",
2026-11-12 17:03:16 +01:00
[string]$DownloadUrl = "https://codealvin.xyz/Alvin-Zilverstand/smt/raw/branch/main/ffmpeg-9.0.2-essentials_build.zip"
2026-09-09 10:21:29 +02:00
)
$ErrorActionPreference = "Stop"
$destinationPath = [System.IO.Path]::GetFullPath($Destination)
$destinationDir = Split-Path -Parent $destinationPath
New-Item -ItemType Directory -Force $destinationDir | Out-Null
if (Test-Path $destinationPath) {
Write-Host "FFmpeg sidecar already exists: $destinationPath"
exit 0
}
$systemFfmpeg = Get-Command ffmpeg -ErrorAction SilentlyContinue
if ($systemFfmpeg) {
Copy-Item -LiteralPath $systemFfmpeg.Source -Destination $destinationPath -Force
Write-Host "Copied system FFmpeg to sidecar: $destinationPath"
exit 0
}
$tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("clipforge-ffmpeg-" + [System.Guid]::NewGuid().ToString("N"))
$zipPath = Join-Path $tempRoot "ffmpeg.zip"
New-Item -ItemType Directory -Force $tempRoot | Out-Null
try {
Write-Host "Downloading FFmpeg essentials build..."
Invoke-WebRequest -UseBasicParsing -Uri $DownloadUrl -OutFile $zipPath
2026-11-12 16:54:11 +01:00
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $tempRoot)
2026-09-09 10:21:29 +02:00
$ffmpeg = Get-ChildItem -Path $tempRoot -Recurse -Filter ffmpeg.exe | Select-Object -First 1
if (-not $ffmpeg) {
throw "Downloaded archive did not contain ffmpeg.exe"
}
Copy-Item -LiteralPath $ffmpeg.FullName -Destination $destinationPath -Force
Write-Host "Prepared FFmpeg sidecar: $destinationPath"
} finally {
Remove-Item -LiteralPath $tempRoot -Recurse -Force -ErrorAction SilentlyContinue
}