-
Notifications
You must be signed in to change notification settings - Fork 1
/
upscale.ps1
37 lines (30 loc) · 1.18 KB
/
upscale.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
param (
[Parameter(Mandatory = $true)][string]$dest_dir,
[Parameter(Mandatory = $true)][string]$source_glob
)
$ErrorActionPreference = "Stop"
Write-Output "Started upscale loop..."
while ($true) {
foreach ($source in Get-Item $source_glob | Sort-Object) {
$temp = Join-Path $dest_dir ($source.BaseName + "-UPHD.tmp")
$raw = Join-Path $dest_dir ($source.BaseName + "-UPHD.mp4")
if (Test-Path -LiteralPath $raw -PathType Leaf) {
continue
}
Write-Output "Upscaling $source"
$env:infer_vspipe = "runtime\vspipe --arg input=`"$source`" -c y4m `"inference.py`" -"
$env:infer_ffmpeg = @("ffmpeg",
"-i - -i `"$source`"",
"-map 0:v -map 1:a -map 1:s?",
"-c:a copy -c:s mov_text -c:v h264_nvenc",
"-max_interleave_delta 0 -rc:v vbr -cq:v 5 -pix_fmt yuv420p",
"-hide_banner -loglevel warning -stats -y -f mp4 `"$temp`"") -join " "
$env:CUDA_MODULE_LOADING = "LAZY"
cmd /s /c --% "%infer_vspipe% | %infer_ffmpeg%"
if (! $?) {
exit 1
}
Move-Item -LiteralPath "$temp" -Destination "$raw"
}
Start-Sleep 60
}