Complete end-to-end automation of YouTube Shorts face-swapping with both CLI and GUI interfaces.
- CLI Interface - Fully automated command-line pipeline
- GUI Interface - User-friendly graphical interface with desktop integration
- Resume Capability - Resume incomplete jobs that failed mid-processing
- YouTube Download - Automatic download of YouTube Shorts
- Face Swapping - Batch face-swap all video frames using InsightFace
- GPU Acceleration - CUDA support for faster processing
- Gender Filtering - Target specific genders for face swapping
- Person Targeting - Swap faces of specific individuals using reference images
- Watermarking - Optional watermark on output videos
- Progress Tracking - Real-time progress monitoring
- Downloads YouTube Short (or uses local video file)
- Extracts video into frames
- Batch face-swaps all frames using InsightFace + inswapper
- Rebuilds video from swapped frames
- Adds original audio to final video
- shortswap.sh - Main automated CLI pipeline
- shortswap_gui.py - Graphical user interface
- run_shortswap_gui.sh - GUI launcher script
- resume_shortswap.sh - Resume incomplete/failed jobs
- impostr_cli.py - Face-swapping engine
- youtube_shorts_downloader.py - YouTube download component
- ShortSwap_README.md - CLI documentation
- ShortSwap_GUI_README.md - GUI documentation
- impostr_cli_README.md - Face-swapping component docs
- youtube_shorts_downloader_README.md - YouTube downloader docs
- Python 3.7+
- ffmpeg
- CUDA toolkit (optional, for GPU acceleration)
pip install insightface onnxruntime opencv-python Pillow numpy
# For GPU support:
pip install onnxruntime-gpuDownload the inswapper_128.onnx model and place it in models/ directory:
- Model: inswapper_128.onnx
- Size: ~554MB
- Download: InsightFace Model Zoo
# Basic usage with YouTube URL
./shortswap.sh --url <YOUTUBE_URL> --face <SOURCE_IMAGE>
# With GPU acceleration
./shortswap.sh --url <YOUTUBE_URL> --face <SOURCE_IMAGE> --cuda
# With local video file
./shortswap.sh --video <VIDEO_FILE> --face <SOURCE_IMAGE>
# With gender filtering
./shortswap.sh --url <YOUTUBE_URL> --face <SOURCE_IMAGE> --gender male --cuda# Launch GUI
./run_shortswap_gui.sh
# Or directly
python3 shortswap_gui.py# Resume an incomplete job
./resume_shortswap.sh <job_directory> <source_face_image> --cudaThe GUI includes desktop integration with:
- Desktop launcher icon
- Application menu entry
- Icon:
/home/panda/Pictures/logos/shortswap_logo.jpg
Desktop files:
~/Desktop/shortswap.desktop~/.local/share/applications/shortswap.desktop
- CPU Processing: 7-22 minutes for 15-second video
- GPU Processing: 45 seconds - 4 minutes for 15-second video
Target only male or female faces:
./shortswap.sh --url <URL> --face <IMAGE> --gender male
./shortswap.sh --url <URL> --face <IMAGE> --gender femaleSwap face of a specific person using a reference image:
./shortswap.sh --url <URL> --face <SOURCE> --target-person <REFERENCE_IMAGE>Add watermark to output videos:
./shortswap.sh --url <URL> --face <IMAGE> --watermarkShortSwap Pipeline:
├── YouTube Download (youtube_shorts_downloader.py)
├── Frame Extraction (ffmpeg)
├── Face Swapping (impostr_cli.py + InsightFace)
├── Video Reconstruction (ffmpeg)
└── Audio Integration (ffmpeg)
If the computer freezes mid-processing, use the resume script:
./resume_shortswap.sh /path/to/job/directory /path/to/face/image --cudaThis will:
- Identify incomplete/failed frames
- Re-process only the missing frames
- Complete the video assembly
If you encounter GPU memory errors:
- Use CPU mode (remove
--cudaflag) - Close other GPU-intensive applications
- Reduce video resolution before processing
If frames have no detectable faces, they will be saved as-is without swapping.
This project uses InsightFace for face detection and swapping. Please review their license terms.
Built with:
- InsightFace - Face detection and swapping
- ONNX Runtime - Model inference
- yt-dlp - YouTube downloading
- FFmpeg - Video processing
Generated with Claude Code
Co-Authored-By: Claude [email protected]