# Download static ffmpeg into desktop/runtime/ffmpeg/ (Windows x64 essentials) $ErrorActionPreference = "Stop" $Root = Split-Path -Parent $PSScriptRoot $Dest = Join-Path $Root "runtime\ffmpeg" $DestExe = Join-Path $Dest "ffmpeg.exe" New-Item -ItemType Directory -Force -Path $Dest | Out-Null if ((Test-Path $DestExe) -and -not $env:DY_FFMPEG_FORCE) { Write-Host "OK (exists) -> $DestExe" & $DestExe -version | Select-Object -First 1 exit 0 } $Zip = Join-Path $env:TEMP "dy-desktop-ffmpeg.zip" # Smaller essentials build (enough for RTMPS relay / Shorts) $Url = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip" # Fallback to full static gpl if essentials URL shape changes — prefer shared/essentials when available $UrlStatic = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip" Write-Host "Downloading ffmpeg..." try { Invoke-WebRequest -Uri $Url -OutFile $Zip -UseBasicParsing } catch { Write-Host "shared build failed, trying full static..." Invoke-WebRequest -Uri $UrlStatic -OutFile $Zip -UseBasicParsing } $Extract = Join-Path $env:TEMP "dy-desktop-ffmpeg-extract" if (Test-Path $Extract) { Remove-Item -Recurse -Force $Extract } Expand-Archive -Path $Zip -DestinationPath $Extract -Force $Bin = Get-ChildItem -Path $Extract -Recurse -Filter "ffmpeg.exe" | Select-Object -First 1 if (-not $Bin) { throw "ffmpeg.exe not found in archive" } Copy-Item $Bin.FullName $DestExe -Force $Probe = Get-ChildItem -Path $Extract -Recurse -Filter "ffprobe.exe" | Select-Object -First 1 if ($Probe) { Copy-Item $Probe.FullName (Join-Path $Dest "ffprobe.exe") -Force } # Copy sibling DLLs if shared build Get-ChildItem -Path $Bin.Directory.FullName -Filter "*.dll" -ErrorAction SilentlyContinue | ForEach-Object { Copy-Item $_.FullName (Join-Path $Dest $_.Name) -Force } Write-Host "OK -> $DestExe" & $DestExe -version | Select-Object -First 1