Files
Video-Processing-Scripts/skill/index.md
T

141 lines
6.9 KiB
Markdown

# Video Processing PowerShell Scripts
A collection of PowerShell scripts for video processing tasks using ffmpeg and ffprobe.
## Prerequisites
- **PowerShell 7+** (pwsh.exe)
- **Platform**: tested on Windows 11 only. Linux and WSL are not tested and not supported.
- **ffmpeg** - Must be in system PATH. Not needed by Get-FramesCount.ps1, Get-VideoInfo.ps1 and Create-FullSubtitle.ps1.
- **ffprobe** - Must be in system PATH. Not needed by Stitch-InBetween.ps1.
- **rife-ncnn-vulkan** - Must be in system PATH and also defined the environment variable **RIFE_HOME** to the same directory
- **upscayl-bin** - Must be in system PATH and also defined the environment variable **UPSCAYL_HOME** to the same directory
## ffmpeg
To install ffmpeg on Windows, download it from [ffmpeg.org](https://ffmpeg.org/download.html) and add it to your system PATH.
## rife-ncnn-vulkan
To install rife-ncnn-vulkan on Windows, see the [RIFE 4.26 installation guide](RIFE.md). Add it to your system PATH.
## upscayl-bin
To install upscayl-bin on Windows, see the [Upscalers installation guide](Upscalers.md). Add it to your system PATH.
## NCNN_GPU_ID
The environment variable **NCNN_GPU_ID** is used to specify the GPU device ID for ncnn-based applications.
This environment variable must be set for both `rife-ncnn-vulkan` and `upscayl-bin`.
The value stored in **NCNN_GPU_ID** will be either:
- **`0`** — use the first Vulkan-capable GPU (device index 0). If you have multiple GPUs, they'd be `0`, `1`, `2`, etc.
- **`-1`** — use CPU only (no Vulkan GPU is available).
These map directly to the `-g` flag values accepted by both `rife-ncnn-vulkan` and `upscayl-bin`:
| `-g` value | Meaning |
| --- | --- |
| `0` | First GPU |
| `1` | Second GPU |
| `2` | Third GPU |
| `-1` | CPU |
---
## Scripts Overview
| Script | Purpose |
| :--- | :--- |
| Clone-Image.ps1 | Clone/copy image files with optional resizing (cover-scale then crop), format conversion, and quality/compression settings |
| Clone-Video.ps1 | Clone/copy video files with optional frame range and sequence extraction |
| Compare-Videos.ps1 | Combine 2 to 4 video files into a single 1920x1080 side-by-side or grid comparison video |
| Create-Clip.ps1 | Create a clip of a frame range from a video, named from the source with a suffix (default `-Clip`) |
| Create-FullSubtitle.ps1 | Creates a full subtitle file from a video file and two SRT subtitle files by combining them with adjusted timing and sequential numbering |
| Create-PillarBox.ps1 | Wrap a video in a 16:9 frame with selectable side-bar effects (black, white, blurred-background variants) |
| Create-Scenes.ps1 | Detect scene changes with ffmpeg and extract each scene as a separate clip using Create-Clip.ps1 |
| Create-ShortClip.ps1 | Create short clips from videos with cropping and overlay options |
| Create-Turnaround.ps1 | Combine a sequence of images into a single turnaround (character reference sheet) image, in a row or a grid |
| Crop-Clips.ps1 | Batch crop videos generated by LTX-2, Kling and Wan from their non-standard resolutions to standard ones (also scales any square video to 1080x1080) |
| Get-Frame.ps1 | Extract a specific frame of a video to PNG, with the image name derived from the video and frame index |
| Get-FramesCount.ps1 | Get total frame count of a video |
| Get-FramesRange.ps1 | Extract a range of frames to PNG images |
| Get-LastFrame.ps1 | Extract a specific frame or last frame to PNG, with an optional filename pattern |
| Get-VideoAudio.ps1 | Extracts audio in either WAV or MP3 format from a video file |
| Get-VideoInfo.ps1 | Extract and display video metadata from comment tags |
| Stitch-InBetween.ps1 | Generate interpolated in-between frames between two images using RIFE and encode to video |
**Important**:
- All scripts require PowerShell 7+ (use `pwsh.exe`)
- Each script has its own Windows command file (`.cmd`) that calls the PowerShell script
## Scripts Installation
The scripts are available from two locations:
- SVN: **public-svn**, project: **Video Processing Scripts**.
- Git: **git.gurusushi.dyndns.org**, repository: **guru/Video-Processing-Scripts**.
```bash title="Clone the repository from Git"
git clone https://git.gurusushi.dyndns.org/guru/Video-Processing-Scripts.git
```
**Note**: there is a `Update-Video-Processing-Scripts.cmd` script that can be used to update the directory from Git to get the latest version.
Add the project folder to your PATH environment variable to access the scripts from any location.
---
## Agent Skill
[SKILL.md](SKILL.md) is an agent skill for AI coding agents (such as Claude Code or Devin). It teaches the agent how to use these scripts safely, so the agent does not have to rediscover the documentation for each task.
What it covers:
- **Prerequisites and environment**: PowerShell 7+, ffmpeg, ffprobe, rife-ncnn-vulkan and upscayl-bin, and the `RIFE_HOME`, `UPSCAYL_HOME` and `NCNN_GPU_ID` variables. The agent checks them once before first use, and stops to ask you if something is missing instead of installing it.
- **Safety rules**: it always previews with `-WhatIf` first, never passes `-Confirm`, and lists which scripts overwrite or delete existing files.
- **Script catalog**: every script with a one-line purpose and a link to its page. The agent loads a page only when it needs the details.
- **Workflows and troubleshooting**: common recipes, such as clipping a frame range or detecting scenes, and the documented error messages with their fixes.
To use it, copy the whole skill folder, not only `SKILL.md`, into your agent's skills folder, and name the copy `video-processing-scripts`. `SKILL.md` links to the documentation pages by relative path, so those pages must sit next to it. For example:
- Devin: `.devin/skills/video-processing-scripts/`
- Claude Code: `.claude/skills/video-processing-scripts/`
The skill folder is available in both repositories:
- **Git** (`guru/Video-Processing-Scripts`): the `skill` folder.
- **SVN** (project `Video Processing Scripts`): the `skill` folder.
Note that both repositories `skill` folder contains `SKILL.md` and the markdown documentation pages required by the skill.
## Notes
- All scripts require PowerShell 7+ (use `pwsh.exe`)
- File extensions (`.mp4`, `.png`) are automatically added if not provided
- Paths can be absolute or relative to current directory
- Use `.skip.mp4` extension to exclude files from batch processing
- Backup files (`.bak.mp4`) are automatically skipped in batch operations
## Troubleshooting
### Error: "Video file not found"
- Check that the file path is correct
- Ensure file exists at specified location
- Use absolute paths if relative paths aren't working
### Error: "ffmpeg failed" or "ffprobe failed"
- Verify ffmpeg and ffprobe are installed and in PATH
- Check that the video file is not corrupted
- Ensure sufficient disk space for output
### Error: "Frame index out of range"
- Use `Get-FramesCount.ps1` to check valid frame range
- Frame indices are 0-based (first frame is 0)