Advertisement
Guest User

Untitled

a guest
Dec 4th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. $ffmpegFilePath = "$PSScriptRoot\ffmpeg.exe"
  2.  
  3. # Check if already exists
  4. if (Test-Path $ffmpegFilePath) {
  5. Write-Host "Skipped downloading ffmpeg, file already exists."
  6. exit
  7. }
  8.  
  9. Write-Host "Downloading ffmpeg..."
  10.  
  11. # Download the zip archive
  12. if ($IsWindows) {
  13. $url = "https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.0/ffmpeg-4.0.1-win-64.zip"
  14. }
  15. if ($IsLinux) {
  16. $url = "https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.0/ffmpeg-4.0.1-linux-64.zip"
  17. }
  18.  
  19. if ($IsMacOS) {
  20. $url = "https://github.com/vot/ffbinaries-prebuilt/releases/download/v4.0/ffmpeg-4.0.1-osx-64.zip"
  21. }
  22.  
  23. [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  24. $wc = New-Object System.Net.WebClient
  25. $wc.DownloadFile($url, "$ffmpegFilePath.zip")
  26. $wc.Dispose()
  27.  
  28. # Extract ffmpeg from the archive
  29. Add-Type -Assembly System.IO.Compression.FileSystem
  30. $zip = [IO.Compression.ZipFile]::OpenRead("$ffmpegFilePath.zip")
  31.  
  32. if ($IsWindows) {
  33. [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zip.GetEntry("ffmpeg.exe"), $ffmpegFilePath)
  34. } else {
  35. [System.IO.Compression.ZipFileExtensions]::ExtractToFile($zip.GetEntry("ffmpeg"), $ffmpegFilePath)
  36. Rename-Item -path $ffmpegFilePath -newname ffmpeg.exe
  37. }
  38.  
  39. $zip.Dispose()
  40.  
  41. # Delete the archive
  42. Remove-Item "$ffmpegFilePath.zip" -Force
  43.  
  44. Write-Host "Done downloading ffmpeg."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement