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
This commit is contained in:
1 parent
c8c5a5d75c
commit
553d0ea18d
3 files changed
+32
-32
No files matched your search
+2
-2
@@ -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
|
echo Error: Create-Clip.ps1 not found in PATH
|
||||||
exit /b 1
|
exit /b 1
|
||||||
:found
|
:found
|
||||||
set "_src=%~1"
|
set "_video=%~1"
|
||||||
set "_frames=%~2"
|
set "_frames=%~2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
@@ -14,4 +14,4 @@ set "_rest=%_rest% %1"
|
|||||||
shift
|
shift
|
||||||
goto loop
|
goto loop
|
||||||
:done
|
: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%
|
||||||
+17
-17
@@ -1,10 +1,10 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates a new clipped video file using Clone-Video.ps1, requiring the -Source and -Frames parameters from that script.
|
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 -Source filename, with "-Clip" inserted before the video file extension (e.g., P01.mp4 becomes P01-Clip.mp4).
|
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 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).
|
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 -Source, -Frames and -Target.
|
Any extra parameters will be pass directly to Clone-Video.ps1, except for parameters -Video, -Frames and -Target.
|
||||||
.PARAMETER Source
|
.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.
|
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
|
.PARAMETER Frames
|
||||||
0-based frames index to extract. Supports the following formats:
|
0-based frames index to extract. Supports the following formats:
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
[CmdletBinding(SupportsShouldProcess)]
|
[CmdletBinding(SupportsShouldProcess)]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Source,
|
[string]$Video,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Frames,
|
[string]$Frames,
|
||||||
@@ -29,25 +29,25 @@ param(
|
|||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
$ErrorActionPreference = 'Stop'
|
$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).
|
# try appending each supported extension in turn (same logic as Clone-Video.ps1).
|
||||||
$supportedSourceExts = @('.mp4', '.webm', '.mkv')
|
$supportedVideoExts = @('.mp4', '.webm', '.mkv')
|
||||||
if (-not (Test-Path -LiteralPath $sourcePath)) {
|
if (-not (Test-Path -LiteralPath $videoPath)) {
|
||||||
foreach ($ext in $supportedSourceExts) {
|
foreach ($ext in $supportedVideoExts) {
|
||||||
$candidate = "$sourcePath$ext"
|
$candidate = "$videoPath$ext"
|
||||||
if (Test-Path -LiteralPath $candidate) {
|
if (Test-Path -LiteralPath $candidate) {
|
||||||
$sourcePath = $candidate
|
$videoPath = $candidate
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Derive the -Target path: insert "-Clip" before the file extension (e.g., P01.mp4 -> P01-Clip.mp4)
|
# Derive the -Target path: insert "-Clip" before the file extension (e.g., P01.mp4 -> P01-Clip.mp4)
|
||||||
$sourceExt = [System.IO.Path]::GetExtension($sourcePath)
|
$sourceExt = [System.IO.Path]::GetExtension($videoPath)
|
||||||
$sourceBase = [System.IO.Path]::GetFileNameWithoutExtension($sourcePath)
|
$sourceBase = [System.IO.Path]::GetFileNameWithoutExtension($videoPath)
|
||||||
$sourceDir = [System.IO.Path]::GetDirectoryName($sourcePath)
|
$sourceDir = [System.IO.Path]::GetDirectoryName($videoPath)
|
||||||
|
|
||||||
# A '.skip' marker must stay immediately before the container extension, so "-Clip" is
|
# 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).
|
# 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('WhatIf')) { $forwarded['WhatIf'] = [bool]$PSBoundParameters['WhatIf'] }
|
||||||
if ($PSBoundParameters.ContainsKey('Confirm')) { $forwarded['Confirm'] = [bool]$PSBoundParameters['Confirm'] }
|
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
|
exit $LASTEXITCODE
|
||||||
+13
-13
@@ -1,7 +1,7 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates a pillar-boxed video file from a video file.
|
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.
|
Path to the input video file. Can be absolute or relative to current directory. .mp4 extension is added if not provided.
|
||||||
.PARAMETER Target
|
.PARAMETER Target
|
||||||
Path to the output video file. Can be absolute or relative to current directory. .mp4 extension is added if not provided.
|
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)]
|
[CmdletBinding(SupportsShouldProcess)]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Source,
|
[string]$Video,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[string]$Target = $null,
|
[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)."
|
throw "Invalid -Effect value: $Effect. Must be one of: $($validEffects -join ', '), or 'color:RRGGBB' (6 hex digits)."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Append .mp4 extension if missing on -Source
|
# Append .mp4 extension if missing on -Video
|
||||||
if (-not [System.IO.Path]::GetExtension($Source)) {
|
if (-not [System.IO.Path]::GetExtension($Video)) {
|
||||||
$Source = "$Source.mp4"
|
$Video = "$Video.mp4"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not (Test-Path -LiteralPath $Source)) {
|
if (-not (Test-Path -LiteralPath $Video)) {
|
||||||
throw "Source video not found: $Source"
|
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).
|
# (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
|
# For 'color:RRGGBB', the colon is replaced with a dash to keep the filename valid
|
||||||
# (e.g. -Effect color:FFFF00 -> video-color-ffff00.mp4).
|
# (e.g. -Effect color:FFFF00 -> video-color-ffff00.mp4).
|
||||||
# With -Vertical, '-vertical' is appended last (e.g. video-black-vertical.mp4).
|
# With -Vertical, '-vertical' is appended last (e.g. video-black-vertical.mp4).
|
||||||
if ([string]::IsNullOrWhiteSpace($Target)) {
|
if ([string]::IsNullOrWhiteSpace($Target)) {
|
||||||
$srcDir = [System.IO.Path]::GetDirectoryName($sourceFull)
|
$srcDir = [System.IO.Path]::GetDirectoryName($videoFull)
|
||||||
$srcBase = [System.IO.Path]::GetFileNameWithoutExtension($sourceFull)
|
$srcBase = [System.IO.Path]::GetFileNameWithoutExtension($videoFull)
|
||||||
$effectForName = $effectLower -replace ':', '-'
|
$effectForName = $effectLower -replace ':', '-'
|
||||||
$verticalForName = if ($Vertical) { '-vertical' } else { '' }
|
$verticalForName = if ($Vertical) { '-vertical' } else { '' }
|
||||||
$Target = Join-Path $srcDir "$srcBase-$effectForName$verticalForName.mp4"
|
$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."
|
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
|
$inRes = "{0}x{1}" -f $inInfo.Width, $inInfo.Height
|
||||||
$inFpsText = if ($inInfo.Fps) { "{0:0.###}" -f $inInfo.Fps } else { 'unknown' }
|
$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' }
|
$effFpsText = if ($effFps) { "{0:0.###}" -f $effFps } else { 'unknown' }
|
||||||
|
|
||||||
# Build ffmpeg arguments
|
# Build ffmpeg arguments
|
||||||
$ffArgs = @('-y', '-i', $sourceFull)
|
$ffArgs = @('-y', '-i', $videoFull)
|
||||||
|
|
||||||
if ($audioFull) {
|
if ($audioFull) {
|
||||||
$ffArgs += @('-i', $audioFull)
|
$ffArgs += @('-i', $audioFull)
|
||||||
|
|||||||
Reference in new issue
Block a user