feat: add Windows and Linux wrapper scripts for VMAF optimizer
This commit is contained in:
87
run_optimisation.ps1
Normal file
87
run_optimisation.ps1
Normal file
@@ -0,0 +1,87 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$Directory = ".",
|
||||
[float]$Vmaf = 95.0,
|
||||
[int]$Preset = 6,
|
||||
[int]$Workers = 1,
|
||||
[int]$Samples = 4,
|
||||
[switch]$Thorough,
|
||||
[string]$Encoder = "svt-av1",
|
||||
[string]$Hwaccel
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Write-ColorOutput {
|
||||
param([string]$Message, [string]$Color = "White")
|
||||
|
||||
Write-Host $Message -ForegroundColor $Color
|
||||
}
|
||||
|
||||
function Invoke-OptimizeLibrary {
|
||||
$scriptPath = Join-Path $PSScriptRoot "optimize_library.py"
|
||||
|
||||
if (-not (Test-Path $scriptPath)) {
|
||||
Write-ColorOutput -Message "ERROR: optimize_library.py not found in current directory" -Color "Red"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$pythonCmd = Get-Command python3, python, py | Select-Object -FirstProperty Path -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCmd) {
|
||||
Write-ColorOutput -Message "ERROR: Python 3 not found. Please install Python 3." -Color "Red"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$arguments = @(
|
||||
$scriptPath,
|
||||
$Directory,
|
||||
"--vmaf", $Vmaf.ToString("F1"),
|
||||
"--preset", $Preset.ToString(),
|
||||
"--workers", $Workers.ToString(),
|
||||
"--samples", $Samples.ToString()
|
||||
"--encoder", $Encoder
|
||||
)
|
||||
|
||||
if ($Thorough) {
|
||||
$arguments += "--thorough"
|
||||
}
|
||||
|
||||
if ($Hwaccel) {
|
||||
$arguments += "--hwaccel", $Hwaccel
|
||||
}
|
||||
|
||||
Write-ColorOutput -Message "Running optimize_library.py..." -Color "Cyan"
|
||||
Write-ColorOutput -Message " Directory: $Directory" -Color "White"
|
||||
Write-ColorOutput -Message " Target VMAF: $Vmaf" -Color "White"
|
||||
Write-ColorOutput -Message " Preset: $Preset" -Color "White"
|
||||
Write-ColorOutput -Message " Workers: $Workers" -Color "White"
|
||||
Write-ColorOutput -Message " Samples: $Samples" -Color "White"
|
||||
Write-ColorOutput -Message " Encoder: $Encoder" -Color "White"
|
||||
if ($Thorough) {
|
||||
Write-ColorOutput -Message " Thorough: Yes" -Color "White"
|
||||
}
|
||||
if ($Hwaccel) {
|
||||
Write-ColorOutput -Message " HW Accel: $Hwaccel" -Color "White"
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
$process = Start-Process -FilePath $pythonCmd.Path -ArgumentList $arguments -NoNewWindow -PassThru
|
||||
|
||||
$process.WaitForExit()
|
||||
$exitCode = $process.ExitCode
|
||||
|
||||
if ($exitCode -eq 0) {
|
||||
Write-ColorOutput -Message "SUCCESS: Library optimization completed" -Color "Green"
|
||||
} else {
|
||||
Write-ColorOutput -Message "ERROR: optimize_library.py exited with code $exitCode" -Color "Red"
|
||||
}
|
||||
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
Write-ColorOutput -Message "========================================" -Color "Cyan"
|
||||
Write-ColorOutput -Message "VMAF Library Optimiser (Windows)" -Color "Yellow"
|
||||
Write-ColorOutput -Message "========================================" -Color "Cyan"
|
||||
Write-Host ""
|
||||
|
||||
Invoke-OptimizeLibrary
|
||||
Reference in New Issue
Block a user