From 553d0ea18dc9facfe5b31c5ad34c8f7e3c1c0fac Mon Sep 17 00:00:00 2001 From: Claude Toupin Date: Sat, 31 Oct 2026 00:20:02 -0400 Subject: [PATCH] Rename -Source parameter to -Video in Create-Clip.ps1 and Create-PillarBox.ps1 for consistency with other scripts, updating all internal variable names (sourcePath->videoPath, sourceFull->videoFull) and documentation references, while preserving .skip marker handling and parameter forwarding logic in Create-Clip.ps1 and maintaining default -Target derivation and effect naming in Create-PillarBox.ps1 --- Create-Clip.cmd | 4 ++-- Create-Clip.ps1 | 34 +++++++++++++++++----------------- Create-PillarBox.ps1 | 26 +++++++++++++------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Create-Clip.cmd b/Create-Clip.cmd index 5bf3586..fcb5f68 100644 --- a/Create-Clip.cmd +++ b/Create-Clip.cmd @@ -3,7 +3,7 @@ for /f "delims=" %%i in ('where Create-Clip.ps1 2^>nul') do set "_script=%%i" & echo Error: Create-Clip.ps1 not found in PATH exit /b 1 :found -set "_src=%~1" +set "_video=%~1" set "_frames=%~2" shift shift @@ -14,4 +14,4 @@ set "_rest=%_rest% %1" shift goto loop :done -pwsh.exe -NoProfile -ExecutionPolicy Bypass -File "%_script%" -Source "%_src%" -Frames "%_frames%"%_rest% +pwsh.exe -NoProfile -ExecutionPolicy Bypass -File "%_script%" -Video "%_video%" -Frames "%_frames%"%_rest% diff --git a/Create-Clip.ps1 b/Create-Clip.ps1 index cf5a69b..066545a 100644 --- a/Create-Clip.ps1 +++ b/Create-Clip.ps1 @@ -1,10 +1,10 @@ <# .SYNOPSIS - Creates a new clipped video file using Clone-Video.ps1, requiring the -Source and -Frames parameters from that script. - The filename used for the -Target parameter is automatically derived from the -Source filename, with "-Clip" inserted before the video file extension (e.g., P01.mp4 becomes P01-Clip.mp4). - When the source name carries a '.skip' marker before its extension, "-Clip" is inserted before that marker so it stays last (e.g., P01.skip.mp4 becomes P01-Clip.skip.mp4). - Any extra parameters will be pass directly to Clone-Video.ps1, except for parameters -Source, -Frames and -Target. -.PARAMETER Source + Creates a new clipped video file using Clone-Video.ps1, requiring the -Video and -Frames parameters. + The filename used for the -Target parameter is automatically derived from the -Video filename, with "-Clip" inserted before the video file extension (e.g., P01.mp4 becomes P01-Clip.mp4). + When the video name carries a '.skip' marker before its extension, "-Clip" is inserted before that marker so it stays last (e.g., P01.skip.mp4 becomes P01-Clip.skip.mp4). + Any extra parameters will be pass directly to Clone-Video.ps1, except for parameters -Video, -Frames and -Target. +.PARAMETER Video Path to the input video file. Can be absolute or relative to current directory. If the path has no extension, .mp4, .webm and .mkv are tried in turn. .PARAMETER Frames 0-based frames index to extract. Supports the following formats: @@ -17,7 +17,7 @@ [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory = $true)] - [string]$Source, + [string]$Video, [Parameter(Mandatory = $true)] [string]$Frames, @@ -29,25 +29,25 @@ param( Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' -$sourcePath = $Source +$videoPath = $Video -# Resolve source path: accept .mp4, .webm or .mkv. If the path doesn't exist as-is, +# Resolve video path: accept .mp4, .webm or .mkv. If the path doesn't exist as-is, # try appending each supported extension in turn (same logic as Clone-Video.ps1). -$supportedSourceExts = @('.mp4', '.webm', '.mkv') -if (-not (Test-Path -LiteralPath $sourcePath)) { - foreach ($ext in $supportedSourceExts) { - $candidate = "$sourcePath$ext" +$supportedVideoExts = @('.mp4', '.webm', '.mkv') +if (-not (Test-Path -LiteralPath $videoPath)) { + foreach ($ext in $supportedVideoExts) { + $candidate = "$videoPath$ext" if (Test-Path -LiteralPath $candidate) { - $sourcePath = $candidate + $videoPath = $candidate break } } } # Derive the -Target path: insert "-Clip" before the file extension (e.g., P01.mp4 -> P01-Clip.mp4) -$sourceExt = [System.IO.Path]::GetExtension($sourcePath) -$sourceBase = [System.IO.Path]::GetFileNameWithoutExtension($sourcePath) -$sourceDir = [System.IO.Path]::GetDirectoryName($sourcePath) +$sourceExt = [System.IO.Path]::GetExtension($videoPath) +$sourceBase = [System.IO.Path]::GetFileNameWithoutExtension($videoPath) +$sourceDir = [System.IO.Path]::GetDirectoryName($videoPath) # A '.skip' marker must stay immediately before the container extension, so "-Clip" is # inserted before it rather than after (e.g., P01.skip.mp4 -> P01-Clip.skip.mp4). @@ -103,5 +103,5 @@ while ($index -lt $extra.Count) { if ($PSBoundParameters.ContainsKey('WhatIf')) { $forwarded['WhatIf'] = [bool]$PSBoundParameters['WhatIf'] } if ($PSBoundParameters.ContainsKey('Confirm')) { $forwarded['Confirm'] = [bool]$PSBoundParameters['Confirm'] } -& $cloneVideoScript -Source $sourcePath -Frames $Frames -Target $targetPath @forwarded +& $cloneVideoScript -Source $videoPath -Frames $Frames -Target $targetPath @forwarded exit $LASTEXITCODE diff --git a/Create-PillarBox.ps1 b/Create-PillarBox.ps1 index eabd717..98d6c26 100644 --- a/Create-PillarBox.ps1 +++ b/Create-PillarBox.ps1 @@ -1,7 +1,7 @@ <# .SYNOPSIS Creates a pillar-boxed video file from a video file. -.PARAMETER Source +.PARAMETER Video Path to the input video file. Can be absolute or relative to current directory. .mp4 extension is added if not provided. .PARAMETER Target Path to the output video file. Can be absolute or relative to current directory. .mp4 extension is added if not provided. @@ -45,7 +45,7 @@ [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory = $true)] - [string]$Source, + [string]$Video, [Parameter(Mandatory = $false)] [string]$Target = $null, @@ -247,25 +247,25 @@ elseif ($effectLower -notin $validEffects) { throw "Invalid -Effect value: $Effect. Must be one of: $($validEffects -join ', '), or 'color:RRGGBB' (6 hex digits)." } -# Append .mp4 extension if missing on -Source -if (-not [System.IO.Path]::GetExtension($Source)) { - $Source = "$Source.mp4" +# Append .mp4 extension if missing on -Video +if (-not [System.IO.Path]::GetExtension($Video)) { + $Video = "$Video.mp4" } -if (-not (Test-Path -LiteralPath $Source)) { - throw "Source video not found: $Source" +if (-not (Test-Path -LiteralPath $Video)) { + throw "Video file not found: $Video" } -$sourceFull = (Resolve-Path -LiteralPath $Source).Path +$videoFull = (Resolve-Path -LiteralPath $Video).Path -# Default -Target: same directory and base name as -Source, with the effect appended +# Default -Target: same directory and base name as -Video, with the effect appended # (e.g. C:\clips\video.mp4 + -Effect Black -> C:\clips\video-black.mp4). # For 'color:RRGGBB', the colon is replaced with a dash to keep the filename valid # (e.g. -Effect color:FFFF00 -> video-color-ffff00.mp4). # With -Vertical, '-vertical' is appended last (e.g. video-black-vertical.mp4). if ([string]::IsNullOrWhiteSpace($Target)) { - $srcDir = [System.IO.Path]::GetDirectoryName($sourceFull) - $srcBase = [System.IO.Path]::GetFileNameWithoutExtension($sourceFull) + $srcDir = [System.IO.Path]::GetDirectoryName($videoFull) + $srcBase = [System.IO.Path]::GetFileNameWithoutExtension($videoFull) $effectForName = $effectLower -replace ':', '-' $verticalForName = if ($Vertical) { '-vertical' } else { '' } $Target = Join-Path $srcDir "$srcBase-$effectForName$verticalForName.mp4" @@ -296,7 +296,7 @@ if ($CRF -ne -1 -and ($CRF -lt 0 -or $CRF -gt 51)) { throw "Invalid -CRF value: $CRF. Must be in range 0-51." } -$inInfo = Get-VideoInfo -Path $sourceFull +$inInfo = Get-VideoInfo -Path $videoFull $inRes = "{0}x{1}" -f $inInfo.Width, $inInfo.Height $inFpsText = if ($inInfo.Fps) { "{0:0.###}" -f $inInfo.Fps } else { 'unknown' } @@ -370,7 +370,7 @@ $effFps = if ($FPS -gt 0) { $FPS } elseif ($inInfo.Fps) { $inInfo.Fps } else { $ $effFpsText = if ($effFps) { "{0:0.###}" -f $effFps } else { 'unknown' } # Build ffmpeg arguments -$ffArgs = @('-y', '-i', $sourceFull) +$ffArgs = @('-y', '-i', $videoFull) if ($audioFull) { $ffArgs += @('-i', $audioFull)