From c79451b373a0614fd1aa3a89ddb2b09532ec4361 Mon Sep 17 00:00:00 2001 From: Claude Toupin Date: Sun, 1 Nov 2026 16:58:24 -0500 Subject: [PATCH] ix Get-Frame.ps1 parameter forwarding to use preference variable splatting instead of manual array building, preventing positional binding issues, update Get-FramesRange.ps1 to add -y flag for automatic overwrite of existing PNG files, fix Create-ShortClip.ps1 to skip clearing default Frames directory when -Render is used (frames are input not output) and add null checks before Test-Path in cleanup logic, and update documentation in Create-FullSubtitle.ps1 and Create-ShortClip.ps1 to clarify existing --- Create-FullSubtitle.ps1 | 1 + Create-ShortClip.ps1 | 10 +++++++--- Get-Frame.ps1 | 8 ++------ Get-FramesRange.ps1 | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Create-FullSubtitle.ps1 b/Create-FullSubtitle.ps1 index 8d4ad26..e2eb90d 100644 --- a/Create-FullSubtitle.ps1 +++ b/Create-FullSubtitle.ps1 @@ -7,6 +7,7 @@ .DESCRIPTION This script creates a full subtitle file from a video file from three sources: a reference video and two SRT subtitle files. The output file contains all subtitles from the first and second subtitle files with proper timing and numbering. + An existing file at -Output is overwritten without a prompt. Its folder is created if it does not exist. .PARAMETER Video Path to the video file. .PARAMETER Subtitle1 diff --git a/Create-ShortClip.ps1 b/Create-ShortClip.ps1 index 314e9eb..8f3d19d 100644 --- a/Create-ShortClip.ps1 +++ b/Create-ShortClip.ps1 @@ -25,6 +25,10 @@ .DESCRIPTION Creates a short clip video file from a 16:9 video file using the specified plan. See Create-ShortClip.ini for details about the INI format and supported entries for the plan file. + Existing files: with the default -Images (the 'Frames' folder next to the video), files directly in that folder are + deleted before extraction (not with -Render, where they are the input). With an explicit -Images, existing frames matching that pattern are deleted before extraction, + and the Frames folder is not touched. An existing output video is overwritten. The temporary extraction directory is + always removed. The Frames folder is removed after the video is created unless -Keep is given. Supports -WhatIf and -Confirm for safe execution. #> [CmdletBinding(SupportsShouldProcess)] @@ -498,7 +502,7 @@ try { if ($videoDir -eq '') { $videoDir = '.' } $framesDir = Join-Path $videoDir 'Frames' if (Test-Path $framesDir) { - if ($PSCmdlet.ShouldProcess($framesDir, 'Clear existing frames directory')) { + if (-not $Render -and $PSCmdlet.ShouldProcess($framesDir, 'Clear existing frames directory')) { Get-ChildItem -Path $framesDir -File | Remove-Item -Force } } @@ -719,11 +723,11 @@ try { } # Clean up frames directory after video is successfully created - if ((-not $Keep) -and (Test-Path $framesDir) -and ($PSCmdlet.ShouldProcess($framesDir, 'Remove frames directory'))) { + if ((-not $Keep) -and $framesDir -and (Test-Path $framesDir) -and ($PSCmdlet.ShouldProcess($framesDir, 'Remove frames directory'))) { Remove-Item -Path $framesDir -Recurse -Force Write-Host "Frames directory removed: $framesDir" } - elseif ($Keep -and (Test-Path $framesDir)) { + elseif ($Keep -and $framesDir -and (Test-Path $framesDir)) { Write-Host "Frames directory preserved: $framesDir" } } diff --git a/Get-Frame.ps1 b/Get-Frame.ps1 index 2b24ee5..0ca0b7d 100644 --- a/Get-Frame.ps1 +++ b/Get-Frame.ps1 @@ -1,7 +1,7 @@ <# .SYNOPSIS Extracts a specific frame of a video file to a PNG image using Get-LastFrame.ps1, requiring -Video and -Frame parameters from that script. - The image filename used for the -Image parameter is automatically derived from the -Video filename, with a "-" followed by the "-Frame" value padded with zeros (maximum of 4 digits) inserted before the image file extension (e.g., P01.mp4 for frame 10 becomes P01-0010.png). + The image filename used for the -Image parameter is automatically derived from the -Video filename, with a "-" followed by the "-Frame" value padded with zeros (at least 4 digits, wider numbers are not truncated) inserted before the image file extension (e.g., P01.mp4 for frame 10 becomes P01-0010.png). .PARAMETER Video Path to the input video file. Can be absolute or relative to current directory. .PARAMETER Frame @@ -73,9 +73,5 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $getLastFrameScript = Join-Path $scriptDir 'Get-LastFrame.ps1' # Forward common parameters to Get-LastFrame.ps1 -$passThrough = @() -if ($PSBoundParameters.ContainsKey('WhatIf')) { $passThrough += '-WhatIf' } -if ($PSBoundParameters.ContainsKey('Confirm')) { $passThrough += '-Confirm' } - -& $getLastFrameScript -Video $VideoPath -Image $imagePath -Frame $frameToExtract @passThrough +& $getLastFrameScript -Video $VideoPath -Image $imagePath -Frame $frameToExtract -WhatIf:$WhatIfPreference -Confirm:([bool]$PSBoundParameters['Confirm']) exit $LASTEXITCODE diff --git a/Get-FramesRange.ps1 b/Get-FramesRange.ps1 index ba2e5d6..dcf0e80 100644 --- a/Get-FramesRange.ps1 +++ b/Get-FramesRange.ps1 @@ -15,6 +15,7 @@ - all: Extract all frames (same as "0-%") .DESCRIPTION Extracts specific range of frames of a video file to PNG images using ffmpeg. + An existing PNG file with the same name is replaced. Supports -WhatIf and -Confirm for safe execution. #> [CmdletBinding(SupportsShouldProcess)] @@ -135,6 +136,7 @@ for ($frameIndex = $startFrame; $frameIndex -le $endFrame; $frameIndex++) { $videoFilter = 'select=eq(n\,{0})' -f $frameIndex $ffmpegArgs = @( + '-y' '-i', $VideoPath '-vf', $videoFilter '-vsync', 'vfr'