Added old features

This commit is contained in:
bnair123
2025-12-31 23:13:32 +04:00
parent 91418fa898
commit 05a306dc42
4 changed files with 1022 additions and 163 deletions

View File

@@ -5,77 +5,87 @@ param(
[int]$Preset = 6,
[int]$Workers = 1,
[int]$Samples = 4,
[switch]$Thorough,
[string]$Encoder = "svt-av1",
[string]$Hwaccel
[string]$Hwaccel = "",
[switch]$UseHardwareWorker,
[string]$PlexUrl = "",
[string]$PlexToken = "",
[string]$LogDir = "/opt/Optmiser/logs"
)
$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
"--samples", $Samples.ToString(),
"--log-dir", $LogDir
)
if ($Thorough) {
$arguments += "--thorough"
}
if ($Hwaccel) {
$arguments += "--hwaccel", $Hwaccel
}
if ($UseHardwareWorker) {
$arguments += "--use-hardware-worker"
}
if ($PlexUrl) {
$arguments += "--plex-url", $PlexUrl
}
if ($PlexToken) {
$arguments += "--plex-token", $PlexToken
}
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"
}
if ($UseHardwareWorker) {
Write-ColorOutput -Message " Hardware worker: Enabled" -Color "White"
}
if ($PlexUrl -and $PlexToken) {
Write-ColorOutput -Message " Plex refresh: Enabled" -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
}