-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
install_ffmpeg.ps1
56 lines (45 loc) · 1.82 KB
/
install_ffmpeg.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
param (
[switch]$webdl
)
$isAdministrator = [Security.Principal.WindowsPrincipal]::new([Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$arguments = [System.Environment]::GetCommandLineArgs()
# MUST BE RUN AS ADMINISTRATOR, but when run from a webdl, it will not be forced
if (-NOT $isAdministrator -AND -NOT $webdl)
{
$arguments = "& '" +$myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
if (-NOT $isAdministrator)
{
Write-Host "WARNING: This script must be run as administrator to correctly add ffmpeg to the system path."
}
# modified a little from https://adamtheautomator.com/install-ffmpeg/
New-Item -Type Directory -Path C:\ffmpeg
Set-Location C:\ffmpeg
curl.exe -L 'https://github.com/GyanD/codexffmpeg/releases/download/6.0/ffmpeg-6.0-essentials_build.zip' -o 'ffmpeg.zip'
# Expand the Zip
Expand-Archive .\ffmpeg.zip -Force -Verbose
# Move the executable (*.exe) files to the top folder
Get-ChildItem -Recurse -Path .\ffmpeg -Filter *.exe |
ForEach-Object {
$source = $_.FullName
$destination = Join-Path -Path . -ChildPath $_.Name
Move-Item -Path $source -Destination $destination -Force -Verbose
}
# # Clean up
Write-Host "Cleaning up..."
Remove-Item .\ffmpeg\ -Recurse
Remove-Item .\ffmpeg.zip
# List the directory contents
Get-ChildItem
# Prepend the FFmpeg folder path to the system path variable
Write-Host "Adding ffmpeg to the system path..."
[System.Environment]::SetEnvironmentVariable(
"PATH",
"C:\ffmpeg\;$([System.Environment]::GetEnvironmentVariable('PATH','MACHINE'))",
"Machine"
)
Write-Host "ffmpeg has been added to the system path."
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
Write-Host "check it by running ffmpeg -version"