11 KiB
name, description
| name | description |
|---|---|
| video-processing-scripts | Operates a collection of PowerShell 7 scripts that process video and image files with ffmpeg, ffprobe, rife-ncnn-vulkan and upscayl-bin. Covers clipping frame ranges, scene-based clip extraction, frame extraction to PNG, frame counts and video metadata, cropping and resizing to standard, LTX-2, Kling and Wan resolutions, pillar-boxing, side-by-side comparison, turnaround sheets, subtitle merging, audio extraction, AI image upscaling and RIFE frame interpolation. Use this skill when the user asks about video clipping, frame extraction, scene detection, cropping, upscaling, frame interpolation, subtitles, ffmpeg or RIFE workflows, the PowerShell video scripts, or preparing clips for Wan2GP or LTX models. |
Video Processing PowerShell Scripts
A collection of PowerShell 7 scripts that wrap ffmpeg and ffprobe for video and image processing. Some scripts also call rife-ncnn-vulkan (frame interpolation) and upscayl-bin (AI upscaling). Each script has its own page in this documentation, linked from the catalog below.
Prerequisites
- PowerShell 7+ (
pwsh). Required by every script. - ffmpeg and ffprobe on
PATH. Required by every video script. - rife-ncnn-vulkan on
PATH, withRIFE_HOMEset. Required by Stitch-InBetween.ps1. See RIFE installation guide. - upscayl-bin on
PATH, withUPSCAYL_HOMEset. Required by Clone-Image.ps1 when-Upscaleis used. See Upscalers installation guide.
Environment Variables
| Variable | Purpose | Accepted values | Required by |
|---|---|---|---|
RIFE_HOME |
Install folder of rife-ncnn-vulkan (the same folder as its PATH entry). Models are read from %RIFE_HOME%\rife-v4.26. |
Folder path, e.g. C:\tools\rife-ncnn-vulkan\ |
Stitch-InBetween.ps1 |
UPSCAYL_HOME |
Install folder of upscayl-bin (the same folder as its PATH entry). Models are read from %UPSCAYL_HOME%\models. |
Folder path | Clone-Image.ps1 with -Upscale |
NCNN_GPU_ID |
GPU device passed to the -g flag of rife-ncnn-vulkan and upscayl-bin. |
0, 1, 2... (GPU index), -1 (CPU only) |
Stitch-InBetween.ps1, Clone-Image.ps1 with -Upscale |
These must be persistent user or system variables. An agent shell may not inherit variables set only in an interactive session.
Check the Environment
Run these once before the first use in a session:
pwsh --version
ffmpeg -version
ffprobe -version
Get-Command rife-ncnn-vulkan
Get-Command upscayl-bin
"RIFE_HOME=$env:RIFE_HOME"
"UPSCAYL_HOME=$env:UPSCAYL_HOME"
"NCNN_GPU_ID=$env:NCNN_GPU_ID"
If anything is missing or empty, stop. Tell the user exactly what is missing and point to index.md (prerequisites), RIFE.md or Upscalers.md. Do not install software or change environment variables without the user's approval.
Installation and Location
- Git:
git clone https://git.gurusushi.dyndns.org/guru/Video-Processing-Scripts.git(repositoryguru/Video-Processing-Scripts). - SVN:
public-svn, projectVideo Processing Scripts. - The script folder must be on
PATHso scripts can be called from any directory. Update-Video-Processing-Scripts.cmdupdates a Git copy to the latest version. Run it only with the user's approval.
How to Run the Scripts
- Always call a script as
pwsh -NoProfile -File <script>.ps1 <parameters>. - The
.cmdwrappers are Windows-only convenience files. Do not use them in agent commands. - Quote every path that contains spaces.
- Paths can be absolute or relative to the current directory.
pwsh -NoProfile -File .\Create-Clip.ps1 -Video "My Video.mp4" -Frames "100-200"
Conventions
- Frame indices are 0-based: the first frame is
0. - If the extension is omitted,
.mp4,.webmand.mkvare tried in that order (for example Create-Clip.ps1, Create-Scenes.ps1). - Files ending in
.skip.mp4(for exampleP01.skip.mp4) are excluded from batch processing. Batch scripts also skip.bak.mp4backups. - A
.skipmarker stays last in derived output names:P01.skip.mp4givesP01-Clip.skip.mp4(Create-Clip.ps1) andP01-Scene-01.skip.mp4(Create-Scenes.ps1).
Safety Rules
- Never pass
-Confirm. Scripts run without interaction. Only-Confirmmakes them prompt. No script sets aConfirmImpactofHigh, so none prompts by default.Create-Scenes.ps1setsMedium. - Before any script that creates, overwrites or deletes files, run it with
-WhatIf. Show the user the result, then run it for real only if the user agrees. - Never run a script on files the user has not designated. Never delete source videos.
Scripts that replace or delete existing files:
| Script | Behavior |
|---|---|
| Clone-Video.ps1 | Overwrites the -Target file (ffmpeg -y). |
| Create-Clip.ps1 | Overwrites the derived clip, through Clone-Video. |
| Create-Scenes.ps1 | Deletes earlier clips of the same source in the source folder, then overwrites them. |
| Clone-Image.ps1 | Overwrites the -Target image (ffmpeg -y). |
| Compare-Videos.ps1 | Overwrites the -Output file (ffmpeg -y). |
| Create-PillarBox.ps1 | Removes an existing target before writing it. |
| Create-Turnaround.ps1 | Overwrites the -Target image. |
| Crop-Clips.ps1 | In-place when source and target are the same folder, which is the default when both are omitted: writes a .bak.mp4 backup, then removes the original after a successful crop. A separate target folder replaces same-named files. |
| Create-FullSubtitle.ps1 | Overwrites the -Output subtitle file without a prompt. |
| Create-ShortClip.ps1 | Overwrites the output video. With the default -Images and without -Render, clears the Frames folder. With explicit -Images, deletes only matching frames. Removes its temporary folders, and the Frames folder unless -Keep is given. |
| Get-FramesRange.ps1 | Overwrites existing PNG frames with the same name (ffmpeg -y). |
| Get-LastFrame.ps1 | Overwrites the output PNG (ffmpeg -y). Get-Frame.ps1 uses it. |
| Get-VideoAudio.ps1 | Overwrites the output audio file. |
| Stitch-InBetween.ps1 | Deletes an existing -Video output before generating. Deletes everything inside an existing -TempDir. Deletes intermediate PNG frames. |
Run -WhatIf first on every script in this table, and check the output paths before running it for real.
Script Catalog
| Script | Purpose | Typical use |
|---|---|---|
| Clone-Image.ps1 | Resize, convert and optionally AI-upscale images | -Source small.jpg -Target big_4k.png -Upscale 4 -Size 4K |
| Clone-Video.ps1 | Re-encode a video with frame range, size, FPS, audio and CRF options | -Source in.mp4 -Target out.mp4 -Frames "0-100" |
| Compare-Videos.ps1 | Side-by-side or grid comparison of 2 to 4 videos at 1080p or 4K | -S1 a.mp4 -S2 b.mp4 -Output cmp.mp4 |
| Create-Clip.ps1 | Clip a frame range; output name is the source name plus -Suffix (default -Clip) |
-Video P01.mp4 -Frames "100-200" |
| Create-FullSubtitle.ps1 | Merge two SRT files into one with adjusted timing | -Video v.mp4 -Subtitle1 a.srt -Subtitle2 b.srt -Output out.srt |
| Create-PillarBox.ps1 | Wrap a video in a 16:9 frame with side-bar effects | -Video v.mp4 -Effect black |
| Create-Scenes.ps1 | Detect scene changes and create one clip per scene | -Video P01.mp4 -Scene 0.3 -List |
| Create-ShortClip.ps1 | Build a vertical short clip from an INI plan | -Video v.mp4 -Plan plan.ini |
| Create-Turnaround.ps1 | Arrange same-named images into a turnaround sheet | -Source "C:\renders\CharacterA" -Target sheet.png |
| Crop-Clips.ps1 | Batch crop LTX-2, Kling and Wan videos to standard sizes | -Source in_dir -Target out_dir |
| Get-Frame.ps1 | Extract one frame to PNG with an automatic name | -Video P01.mp4 -Frame 10 |
| Get-FramesCount.ps1 | Print the total frame count of a video | -Video P01.mp4 |
| Get-FramesRange.ps1 | Extract a range of frames to PNG files | -Video P01.mp4 -Frames "0-50" |
| Get-LastFrame.ps1 | Extract one frame (default: the last) to a chosen PNG name | -Video P01.mp4 -Image last.png |
| Get-VideoAudio.ps1 | Extract audio as WAV (default) or MP3 | -Video P01.mp4 -MP3 |
| Get-VideoInfo.ps1 | Show metadata stored in video comment tags | -Video *.mp4 |
| Stitch-InBetween.ps1 | Generate in-between frames with RIFE and encode them to video | -First a.png -Last b.png -Frames 30 -Video out.mp4 |
Common Workflows
Clip a frame range (count frames, preview, then run):
pwsh -NoProfile -File .\Get-FramesCount.ps1 -Video P01.mp4
pwsh -NoProfile -File .\Create-Clip.ps1 -Video P01.mp4 -Frames "100-200" -WhatIf
pwsh -NoProfile -File .\Create-Clip.ps1 -Video P01.mp4 -Frames "100-200"
Split a video into scenes (list first, then create clips):
pwsh -NoProfile -File .\Create-Scenes.ps1 -Video P01.mp4 -Scene 0.3 -List
pwsh -NoProfile -File .\Create-Scenes.ps1 -Video P01.mp4 -Scene 0.3 -WhatIf
pwsh -NoProfile -File .\Create-Scenes.ps1 -Video P01.mp4 -Scene 0.3
Extract the last frame to a named PNG:
pwsh -NoProfile -File .\Get-LastFrame.ps1 -Video P01.mp4 -Image last.png
Upscale an image (needs UPSCAYL_HOME, NCNN_GPU_ID and the model files):
pwsh -NoProfile -File .\Clone-Image.ps1 -Source small.jpg -Target big_4k.png -Upscale 4 -Size 4K
Interpolate between two images with RIFE:
pwsh -NoProfile -File .\Stitch-InBetween.ps1 -First frame1.png -Last frame2.png -Frames 30 -Video output.mp4 -FPS 24 -WhatIf
pwsh -NoProfile -File .\Stitch-InBetween.ps1 -First frame1.png -Last frame2.png -Frames 30 -Video output.mp4 -FPS 24
Troubleshooting
- "Video file not found": check the path. Use an absolute path if relative paths fail. See index.md.
- "ffmpeg failed" or "ffprobe failed": run
ffmpeg -versionandffprobe -version. Check that the file is not corrupt and that the disk has space. See index.md. - "Frame index out of range": run Get-FramesCount.ps1. Indices are 0-based.
-Imagerejected by Get-Frame:-Imageis not a Get-Frame.ps1 parameter. Use Get-LastFrame.ps1 for custom names.- Missing
RIFE_HOME,UPSCAYL_HOMEorNCNN_GPU_ID: set the persistent variable as described above. Then start a new shell. - Upscale fails with missing models: the model files
<Model>.binand<Model>.parammust be in%UPSCAYL_HOME%\models. See Clone-Image.md and Upscalers.md.