117 lines
5.1 KiB
Markdown
117 lines
5.1 KiB
Markdown
# Video Processing PowerShell Scripts
|
|
|
|
A collection of PowerShell scripts for video processing tasks using ffmpeg and ffprobe.
|
|
|
|
## Prerequisites
|
|
|
|
- **PowerShell 7+** (pwsh.exe)
|
|
- **ffmpeg** - Must be in system PATH
|
|
- **ffprobe** - Must be in system PATH
|
|
- **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.
|
|
|
|
---
|
|
|
|
## 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)
|