From fcc208e3516d805cbec1bc0fa733e58a5b2c6afe Mon Sep 17 00:00:00 2001 From: Claude Toupin Date: Mon, 2 Nov 2026 19:36:49 -0500 Subject: [PATCH] Change NCNN_GPU_ID=-1 handling in Clone-Image.ps1 to omit upscayl-bin -g flag instead of passing -1 (which the tested build rejects), update documentation across Clone-Image.md, SKILL.md, README.md and index.md to clarify -1 means CPU for rife-ncnn-vulkan but default device for upscayl-bin, wrap Get-SrtContent calls in Create-FullSubtitle.ps1 with @() array operator to ensure Count property exists when parsing returns single entry, fix Get-FramesRange.ps1 output directory resolution to use Resolve-Path before --- Clone-Image.ps1 | 7 ++++--- Create-FullSubtitle.ps1 | 4 ++-- Get-FramesRange.ps1 | 2 +- README.md | 4 ++-- video-processing-scripts/Clone-Image.md | 2 +- video-processing-scripts/SKILL.md | 2 +- video-processing-scripts/index.md | 4 ++-- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Clone-Image.ps1 b/Clone-Image.ps1 index 9f8608d..4c8d341 100644 --- a/Clone-Image.ps1 +++ b/Clone-Image.ps1 @@ -33,7 +33,7 @@ ffmpeg input, so any -Size / -LTX cover-scale-then-crop is applied to the upscaled image. Requires upscayl-bin.exe in PATH, the UPSCAYL_HOME environment variable pointing to the upscayl-bin install directory, and the NCNN_GPU_ID environment variable set to the desired - GPU device ID (-1 for CPU, 0/1/2/... for GPU). + GPU device ID (0/1/2/... for a GPU, or -1 to omit the -g flag so upscayl-bin uses its default device). .PARAMETER Model Upscayl model name (without extension) to use when -Upscale is specified. Defaults to '4xNomos8kSC'. The model files (.bin and .param) must exist under @@ -328,7 +328,7 @@ if ($Upscale -gt 0) { exit 1 } if ($gpuId -notmatch '^-?\d+$') { - Write-Error ('NCNN_GPU_ID must be an integer (-1 for CPU, 0+ for GPU). Current value: {0}' -f $gpuId) + Write-Error ('NCNN_GPU_ID must be an integer (-1 for the default device, 0+ for a GPU index). Current value: {0}' -f $gpuId) exit 1 } @@ -337,7 +337,8 @@ if ($Upscale -gt 0) { Write-Host ('Upscaling source with upscayl-bin (x{0}, model={1}, gpu={2})...' -f $Upscale, $Model, $gpuId) Write-Host (' Upscayl temp file: {0}' -f $upscaledTempPath) - $upscaylArgs = @('-i', $SourcePath, '-o', $upscaledTempPath, '-s', $Upscale.ToString(), '-n', $Model, '-m', $modelsDir, '-g', $gpuId) + $upscaylArgs = @('-i', $SourcePath, '-o', $upscaledTempPath, '-s', $Upscale.ToString(), '-n', $Model, '-m', $modelsDir) + if ([int]$gpuId -ge 0) { $upscaylArgs += @('-g', $gpuId) } $upscaylCmdLine = '"{0}" {1}' -f $upscaylExePath, (($upscaylArgs | ForEach-Object { if ($_ -match '\s') { '"{0}"' -f $_ } else { $_ } }) -join ' ') diff --git a/Create-FullSubtitle.ps1 b/Create-FullSubtitle.ps1 index e2eb90d..7a4e57b 100644 --- a/Create-FullSubtitle.ps1 +++ b/Create-FullSubtitle.ps1 @@ -194,7 +194,7 @@ function Export-SrtFile { #region Main Script Write-Host "Parsing first subtitle file: $Subtitle1" -$subtitle1Entries = Get-SrtContent -SrtPath $Subtitle1 +$subtitle1Entries = @(Get-SrtContent -SrtPath $Subtitle1) Write-Host " Found $($subtitle1Entries.Count) entries" if ($subtitle1Entries.Count -eq 0) { @@ -210,7 +210,7 @@ $videoDurationFormatted = ConvertFrom-TimeSpan -TimeSpan ([TimeSpan]::FromSecond Write-Host " Video duration: $videoDurationFormatted (${videoDuration}s)" Write-Host "Parsing second subtitle file: $Subtitle2" -$subtitle2Entries = Get-SrtContent -SrtPath $Subtitle2 +$subtitle2Entries = @(Get-SrtContent -SrtPath $Subtitle2) Write-Host " Found $($subtitle2Entries.Count) entries" if ($subtitle2Entries.Count -eq 0) { diff --git a/Get-FramesRange.ps1 b/Get-FramesRange.ps1 index 97dcd84..5d67d45 100644 --- a/Get-FramesRange.ps1 +++ b/Get-FramesRange.ps1 @@ -112,7 +112,7 @@ $frameCount = $endFrame - $startFrame + 1 if ([string]::IsNullOrWhiteSpace($Images)) { $videoBaseName = [System.IO.Path]::GetFileNameWithoutExtension($Video) - $outputDir = Split-Path -Parent $VideoPath + $outputDir = Split-Path -Parent (Resolve-Path -LiteralPath $VideoPath).Path $Images = Join-Path $outputDir 'Frames' ($videoBaseName + '_%04d.png') } else { $outputPattern = $Images diff --git a/README.md b/README.md index 2c73a74..d033caf 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ This environment variable must be set for both `rife-ncnn-vulkan` and `upscayl-b The value stored in **NCNN_GPU_ID** will be either: - **`0`** — use the first Vulkan-capable GPU (device index 0). If you have multiple GPUs, they'd be `0`, `1`, `2`, etc. -- **`-1`** — use CPU only (no Vulkan GPU is available). +- **`-1`** — use CPU only for `rife-ncnn-vulkan` (no Vulkan GPU is available). `upscayl-bin` rejects `-g -1` on the tested build, so the scripts omit its `-g` flag for `-1`, and it then uses its default device. These map directly to the `-g` flag values accepted by both `rife-ncnn-vulkan` and `upscayl-bin`: @@ -41,7 +41,7 @@ These map directly to the `-g` flag values accepted by both `rife-ncnn-vulkan` a | `0` | First GPU | | `1` | Second GPU | | `2` | Third GPU | -| `-1` | CPU | +| `-1` | CPU for `rife-ncnn-vulkan`; no `-g` flag for `upscayl-bin` (its default device) | --- diff --git a/video-processing-scripts/Clone-Image.md b/video-processing-scripts/Clone-Image.md index cb60f74..6c632b3 100644 --- a/video-processing-scripts/Clone-Image.md +++ b/video-processing-scripts/Clone-Image.md @@ -188,7 +188,7 @@ The output format is selected from the `-Target` file extension. Each format has - AVIF output uses `libaom-av1` with `-still-picture 1` and `-cpu-used 4` for a reasonable speed/quality tradeoff. Your ffmpeg build must include `libaom-av1` for `.avif` output to work. - `-Metadata` toggles ffmpeg's `-map_metadata 0` (copy) vs `-map_metadata -1` (strip). Which metadata actually survives the conversion depends on what the source and target formats can carry. - `-LTX` only takes effect when `-Size` is `HD`, `1080p`, `720p` or `480p`. Combining it with any other `-Size` value (or omitting `-Size`) is rejected with an explicit error so the user is never silently downgraded to the regular preset. -- `-Upscale` runs `upscayl-bin.exe` **before** ffmpeg. The script validates that `upscayl-bin.exe` is on PATH, that `UPSCAYL_HOME` is set and exists, that the `models` subfolder and the requested `.bin` / `.param` files are present, and that `NCNN_GPU_ID` is set to a valid integer (`-1` for CPU, `0+` for GPU). The intermediate upscaled PNG is created under `%TEMP%` and deleted after the run (including on ffmpeg failure). +- `-Upscale` runs `upscayl-bin.exe` **before** ffmpeg. The script validates that `upscayl-bin.exe` is on PATH, that `UPSCAYL_HOME` is set and exists, that the `models` subfolder and the requested `.bin` / `.param` files are present, and that `NCNN_GPU_ID` is set to a valid integer (`0+` for a GPU index; `-1` omits the `-g` flag, so upscayl-bin uses its default device, which is not necessarily the CPU). The intermediate upscaled PNG is created under `%TEMP%` and deleted after the run (including on ffmpeg failure). - `-Keep` saves the raw upscayl output (no cropping/scaling). When the `-Keep` extension is `.png`, the temp file is copied directly (no re-encode); for any other supported extension a separate ffmpeg invocation converts the PNG to the requested format with default quality settings (JPEG `-q:v 2`, WEBP `-quality 90`, AVIF `-crf 25`). `-Keep` is ignored with a warning if `-Upscale` is not specified. ### Notes diff --git a/video-processing-scripts/SKILL.md b/video-processing-scripts/SKILL.md index d6a9fe6..22b276f 100644 --- a/video-processing-scripts/SKILL.md +++ b/video-processing-scripts/SKILL.md @@ -41,7 +41,7 @@ The filters used (for example `scale`, `crop`, `pad`, `hstack`, `vstack`, `selec | --- | --- | --- | --- | | `RIFE_HOME` | Install folder of rife-ncnn-vulkan (the same folder as its `PATH` entry). Models are read from `%RIFE_HOME%\rife-v4.26`. | Folder path, e.g. `C:\tools\rife-ncnn-vulkan\` | [Stitch-InBetween.ps1](Stitch-InBetween.md) | | `UPSCAYL_HOME` | Install folder of upscayl-bin (the same folder as its `PATH` entry). Models are read from `%UPSCAYL_HOME%\models`. | Folder path | [Clone-Image.ps1](Clone-Image.md) with `-Upscale` | -| `NCNN_GPU_ID` | GPU device passed to the `-g` flag of rife-ncnn-vulkan and upscayl-bin. | `0`, `1`, `2`... (GPU index), `-1` (CPU only) | [Stitch-InBetween.ps1](Stitch-InBetween.md), [Clone-Image.ps1](Clone-Image.md) with `-Upscale` | +| `NCNN_GPU_ID` | GPU device passed to the `-g` flag of rife-ncnn-vulkan and upscayl-bin. | `0`, `1`, `2`... (GPU index), `-1` (CPU for rife-ncnn-vulkan; upscayl-bin gets no `-g` flag and uses its default device) | [Stitch-InBetween.ps1](Stitch-InBetween.md), [Clone-Image.ps1](Clone-Image.md) with `-Upscale` | These must be persistent user or system variables. An agent shell may not inherit variables set only in an interactive session. diff --git a/video-processing-scripts/index.md b/video-processing-scripts/index.md index 2c73a74..d033caf 100644 --- a/video-processing-scripts/index.md +++ b/video-processing-scripts/index.md @@ -32,7 +32,7 @@ This environment variable must be set for both `rife-ncnn-vulkan` and `upscayl-b The value stored in **NCNN_GPU_ID** will be either: - **`0`** — use the first Vulkan-capable GPU (device index 0). If you have multiple GPUs, they'd be `0`, `1`, `2`, etc. -- **`-1`** — use CPU only (no Vulkan GPU is available). +- **`-1`** — use CPU only for `rife-ncnn-vulkan` (no Vulkan GPU is available). `upscayl-bin` rejects `-g -1` on the tested build, so the scripts omit its `-g` flag for `-1`, and it then uses its default device. These map directly to the `-g` flag values accepted by both `rife-ncnn-vulkan` and `upscayl-bin`: @@ -41,7 +41,7 @@ These map directly to the `-g` flag values accepted by both `rife-ncnn-vulkan` a | `0` | First GPU | | `1` | Second GPU | | `2` | Third GPU | -| `-1` | CPU | +| `-1` | CPU for `rife-ncnn-vulkan`; no `-g` flag for `upscayl-bin` (its default device) | ---