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
This commit is contained in:
1 parent
373efac4af
commit
c79451b373
4 files changed
+12
-9
No files matched your search
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -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
|
||||
@@ -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'
|
||||
|
||||
Reference in new issue
Block a user