Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ffmpegFilePath = "$PSScriptRoot\ffmpeg.exe"
- # Check if already exists
- if (Test-Path $ffmpegFilePath) {
- Write-Host "Skipped downloading ffmpeg, file already exists."
- exit
- }
- Write-Host "Downloading ffmpeg..."
- # Download the zip archive
- if ($IsWindows) {
- $url = "https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.0/ffmpeg-4.0.1-win-64.zip"
- }
- if ($IsLinux) {
- $url = "https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.0/ffmpeg-4.0.1-linux-64.zip"
- }
- if ($IsMacOS) {
- $url = "https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.0/ffmpeg-4.0.1-osx-64.zip"
- }
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
- $wc = New-Object System.Net.WebClient
- $wc.DownloadFile($url, "$ffmpegFilePath.zip")
- $wc.Dispose()
- # Extract ffmpeg from the archive
- Add-Type -Assembly System.IO.Compression.FileSystem
- $zip = [IO.Compression.ZipFile]::OpenRead("$ffmpegFilePath.zip")
- if ($IsWindows) {
- [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zip.GetEntry("ffmpeg.exe"), $ffmpegFilePath)
- } else {
- [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zip.GetEntry("ffmpeg"), $ffmpegFilePath)
- Rename-Item -path $ffmpegFilePath -newname ffmpeg.exe
- }
- $zip.Dispose()
- # Delete the archive
- Remove-Item "$ffmpegFilePath.zip" -Force
- Write-Host "Done downloading ffmpeg."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement