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
|
.DESCRIPTION
|
||||||
This script creates a full subtitle file from a video file from three sources: a reference video and two SRT subtitle files.
|
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.
|
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
|
.PARAMETER Video
|
||||||
Path to the video file.
|
Path to the video file.
|
||||||
.PARAMETER Subtitle1
|
.PARAMETER Subtitle1
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a short clip video file from a 16:9 video file using the specified plan.
|
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.
|
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.
|
Supports -WhatIf and -Confirm for safe execution.
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(SupportsShouldProcess)]
|
[CmdletBinding(SupportsShouldProcess)]
|
||||||
@@ -498,7 +502,7 @@ try {
|
|||||||
if ($videoDir -eq '') { $videoDir = '.' }
|
if ($videoDir -eq '') { $videoDir = '.' }
|
||||||
$framesDir = Join-Path $videoDir 'Frames'
|
$framesDir = Join-Path $videoDir 'Frames'
|
||||||
if (Test-Path $framesDir) {
|
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
|
Get-ChildItem -Path $framesDir -File | Remove-Item -Force
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,11 +723,11 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Clean up frames directory after video is successfully created
|
# 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
|
Remove-Item -Path $framesDir -Recurse -Force
|
||||||
Write-Host "Frames directory removed: $framesDir"
|
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"
|
Write-Host "Frames directory preserved: $framesDir"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-6
@@ -1,7 +1,7 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.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.
|
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
|
.PARAMETER Video
|
||||||
Path to the input video file. Can be absolute or relative to current directory.
|
Path to the input video file. Can be absolute or relative to current directory.
|
||||||
.PARAMETER Frame
|
.PARAMETER Frame
|
||||||
@@ -73,9 +73,5 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|||||||
$getLastFrameScript = Join-Path $scriptDir 'Get-LastFrame.ps1'
|
$getLastFrameScript = Join-Path $scriptDir 'Get-LastFrame.ps1'
|
||||||
|
|
||||||
# Forward common parameters to Get-LastFrame.ps1
|
# Forward common parameters to Get-LastFrame.ps1
|
||||||
$passThrough = @()
|
& $getLastFrameScript -Video $VideoPath -Image $imagePath -Frame $frameToExtract -WhatIf:$WhatIfPreference -Confirm:([bool]$PSBoundParameters['Confirm'])
|
||||||
if ($PSBoundParameters.ContainsKey('WhatIf')) { $passThrough += '-WhatIf' }
|
|
||||||
if ($PSBoundParameters.ContainsKey('Confirm')) { $passThrough += '-Confirm' }
|
|
||||||
|
|
||||||
& $getLastFrameScript -Video $VideoPath -Image $imagePath -Frame $frameToExtract @passThrough
|
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
- all: Extract all frames (same as "0-%")
|
- all: Extract all frames (same as "0-%")
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Extracts specific range of frames of a video file to PNG images using ffmpeg.
|
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.
|
Supports -WhatIf and -Confirm for safe execution.
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(SupportsShouldProcess)]
|
[CmdletBinding(SupportsShouldProcess)]
|
||||||
@@ -135,6 +136,7 @@ for ($frameIndex = $startFrame; $frameIndex -le $endFrame; $frameIndex++) {
|
|||||||
$videoFilter = 'select=eq(n\,{0})' -f $frameIndex
|
$videoFilter = 'select=eq(n\,{0})' -f $frameIndex
|
||||||
|
|
||||||
$ffmpegArgs = @(
|
$ffmpegArgs = @(
|
||||||
|
'-y'
|
||||||
'-i', $VideoPath
|
'-i', $VideoPath
|
||||||
'-vf', $videoFilter
|
'-vf', $videoFilter
|
||||||
'-vsync', 'vfr'
|
'-vsync', 'vfr'
|
||||||
|
|||||||
Reference in new issue
Block a user