VidTrainPrep
Python GUI tool for preparing video datasets (LORA, Wan, Hunyuan training). Features range clipping, cropping, FPS conversion & optional Gemini descriptions. (Enhanced refactor of HunyClip).
Install / Use
/learn @lovisdotio/VidTrainPrepREADME
VidTrainPrep
VidTrainPrep is a Python-based tool designed for clipping and preparing video data, specifically tailored for creating datasets for training video models like LORA, Wan, or Hunyuan. It allows for precise range selection, cropping, FPS conversion, and optional AI-powered description generation using the Gemini API.
Acknowledgement: This tool is a significant refactoring and enhancement based on the original HunyClip by Tr1dae.
(Note: Screenshot might be slightly outdated)
Key Features
- Range-Based Clipping: Define multiple start/end points (ranges) within a single source video, instead of just one trim point.
- Interactive Range Creation: Create new clip ranges visually by drawing a crop rectangle on the desired start frame. The duration set in the UI is used to determine the end frame.
- Independent Range Cropping: Assign a unique crop region to each defined range.
- FPS Conversion Tool: Pre-process videos in a selected folder by converting them to a target FPS (e.g., 30 FPS) into a new subfolder, crucial for training consistency.
- Gemini Integration (Optional):
- Automatically generate descriptions for exported video ranges using the Gemini API (requires API key), helpful for creating captions or prompts.
- Optionally prepend a custom Trigger Word (e.g.,
MyLoraTag, ...) to generated descriptions/captions. - Optionally provide a Character Name to be included in the prompt sent to Gemini for more personalized descriptions.
- Flexible Export Options:
- Export cropped video clips.
- Export uncropped video clips (full frame, but timed to the range).
- Export an image frame from the start of each selected range.
- Modern UI: Refreshed dark monochrome theme.
- Session Saving: Remembers the selected folder, defined ranges, and export settings.
- Keyboard Shortcuts: For faster navigation and editing.
Installation (Windows Focus)
Prerequisites
- Python: 3.8 or higher recommended. Download from python.org. Ensure Python and Pip are added to your system's PATH during installation.
- FFmpeg: Required for video processing (cropping, FPS conversion).
- Download from ffmpeg.org (e.g., the
gyan.devbuilds for Windows). - Extract the downloaded archive.
- Crucially, add the
bindirectory (containingffmpeg.exe,ffprobe.exe) to your system's PATH environment variable. You can find guides online on how to add directories to the PATH on Windows.
- Download from ffmpeg.org (e.g., the
- Git: Optional, but recommended for cloning. Download from git-scm.com.
Steps
-
Clone or Download:
- Using Git (Recommended):
git clone https://github.com/lovisdotio/VidTrainPrep.git # Replace with your repo URL if forked cd VidTrainPrep - Download ZIP: Download the repository ZIP from GitHub, extract it, and open a terminal (like Command Prompt or PowerShell) in the extracted folder.
- Using Git (Recommended):
-
Run the Setup Script:
- Double-click the
Start.batfile. - This script will automatically:
- Create a Python virtual environment (
venvfolder). - Activate the environment.
- Install all required Python packages (PyQt6, ffmpeg-python, google-generativeai, Pillow, etc.) from
requirements.txt. - Launch the application (
main.py).
- Create a Python virtual environment (
- Double-click the
Usage Workflow
- Select Folder: Click
Select Folderand choose the directory containing your source videos. - (Optional) Convert FPS:
- Click
Convert FPS.... - Enter the desired Target FPS (e.g., 30) and a name for the output subfolder (e.g.,
converted_30fps). - Click
OK. The conversion process will run in the background (check console output). - Once complete, the application will automatically reload using the new subfolder.
- Click
- Load Video: Click a video name in the "Video Files" list.
- Define Clip Ranges:
- Navigate: Use the slider to find the desired start frame for your first clip.
- Set Duration: Enter the desired clip duration (in frames) in the "Duration (f)" field.
- Create Range by Cropping: Click and drag on the video preview to define the crop region. When you release the mouse, a new range will be added to the "Clip Ranges" list, starting at the current frame, using the specified duration, and including the crop you drew.
- Create Range without Cropping: Click the
Add Range Herebutton. This adds a range at the current frame with the specified duration, but without a crop. - Repeat: Navigate to other start frames, adjust duration, and draw crops (or click
Add Range Here) to define all the ranges you need from this source video.
- Manage Ranges:
- Select: Click a range in the "Clip Ranges" list to view/edit its properties.
- Adjust Duration: Select a range and modify the "Duration (f)" field. The end frame is calculated automatically.
- Update Crop: Select a range and simply draw a new crop rectangle on the video. The selected range's crop will be updated.
- Clear Crop: Select a range and click
Clear Crop for Selected Range. - Remove: Select a range and click
Remove Range. - Preview: Select a range and press
Zto loop playback within that range.
- Configure Export Options:
- Checkboxes: Select whether to export cropped clips, uncropped clips, and/or an image from the start frame of each range.
- (Optional) Output Res: Set a maximum longest edge for exported videos (requires FFmpeg scaling).
- (Optional) Filename Prefix: Enter text to replace the original filename part.
- (Optional) Trigger Word: Enter a word/tag to prepend to Gemini descriptions (e.g.,
mydata, ...). - (Optional) Character Name: Enter the subject's name to include in Gemini prompts.
- (Optional) Gemini: Enter your Gemini API Key and check "Generate Gemini..." to enable AI descriptions/captions.
- Select Videos for Export: In the main "Video Files" list, check the box next to each video source whose defined ranges you want to export.
- Export: Click
Export Selected Video(s). The application will process each checked video, exporting files for each of its defined ranges into thecroppedand/oruncroppedsubfolders based on your settings.
Keyboard Shortcuts
- Z: Preview (Loop) selected range.
- C: Play/Pause normal playback from current position.
- X: Select Next Video in the main list.
- A / S: Nudge Start Frame Left / Right (of selected range - updates duration).
- Q / W: Nudge End Frame Left / Right (by changing duration).
- Delete / Backspace: Remove selected range (when range list has focus).
Contributing
Contributions or suggestions are welcome! Please fork the repository and create a pull request with your changes.
Acknowledgments
- Original HunyClip concept and base: Tr1dae
- PyQt6 for the GUI framework.
- OpenCV and FFmpeg (via ffmpeg-python) for video processing.
- Google Gemini API (via google-generativeai) for AI descriptions.
Related Skills
qqbot-channel
346.8kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.1k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
346.8kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
Design
Campus Second-Hand Trading Platform \- General Design Document (v5.0 \- React Architecture \- Complete Final Version)1\. System Overall Design 1.1. Project Overview This project aims t
