A powerful tool to automatically convert long-form videos into engaging YouTube Shorts using AI analysis and professional video effects.
Detailed description about this project can be found in the blog post. π¨βπ» Want to learn more about the author? Check out vitaliihonchar.com or the YouTube channel for more content!
- π― AI-Powered Content Analysis - Uses OpenAI/OpenRouter to identify the best moments for shorts with strict duration requirements
- π¬ Professional Video Effects Pipeline - Automated video enhancement with:
- 9:16 vertical format conversion with smart cropping/blurred background
- Audio normalization to YouTube standards (-14 LUFS)
- Dynamic text overlays (title and captions)
- Speed adjustment (1.35x default) with pitch preservation
- High-quality H.264 encoding optimized for mobile viewing
- π Smart Transcription - Powered by faster-whisper for accurate speech-to-text with timestamp precision
- π YouTube-Ready Metadata - Automatically generates:
- SEO-optimized titles and descriptions (300+ characters)
- 20-50 relevant tags for maximum discoverability
- Upload-ready content packages with proper formatting
- π Progress Tracking - Real-time progress bars for all pipeline operations
- π¨ Multiple Video Effect Strategies - Configurable video processing approaches
- βοΈ Highly Configurable - Comprehensive command-line arguments and environment variables
- Python 3.13+
- FFmpeg installed on your system
- OpenAI API key (or compatible service like OpenRouter)
Clone the repository and install as a global tool:
git clone git@github.com:vitalii-honchar/youtube-shorts-creator.git
cd youtube-shorts-creator
uv tool install -e .This creates a global shorts-creator command you can run from anywhere.
Create a .env file in your working directory with the required API key:
# Required: OpenAI API key
YOUTUBE_SHORTS_OPENAI_API_KEY=your-api-key-here
# Optional: Custom API endpoint (defaults to OpenRouter)
YOUTUBE_SHORTS_OPENAI_BASE_URL=https://openrouter.ai/api/v1
# Optional: Model selection (defaults to gpt-5-mini)
YOUTUBE_SHORTS_MODEL_NAME=openai/gpt-5-mini
# Optional: Default settings
YOUTUBE_SHORTS_SHORTS_NUMBER=3
YOUTUBE_SHORTS_SHORT_DURATION_SECONDS=60
YOUTUBE_SHORTS_SPEED_FACTOR=1.35
YOUTUBE_SHORTS_WHISPER_MODEL_SIZE=medium# Process a video with default settings
shorts-creator -v /path/to/your/video.mp4| Argument | Short | Description | Default |
|---|---|---|---|
--video |
-v |
Path to input video file | Required |
--shorts |
-s |
Number of shorts to generate | 3 |
--short-duration |
-sd |
Minimum duration of each short in seconds | 60 |
--duration |
-d |
Max input video duration to process (seconds) | None (full video) |
--strategy |
Video effects strategy (basic) | basic | |
--debug |
Enable debug mode with verbose logging | false | |
--no-refresh |
-nr |
Use cached files if available (opposite of refresh) | true |
Note: By default, the tool refreshes/regenerates content. Use -nr to use cached files.
# Generate 3 shorts with minimum 30 seconds each
shorts-creator -v tutorial.mp4 -s 3 -sd 30
# Process only first 5 minutes of a long video
shorts-creator -v long-lecture.mp4 -d 300 -s 4
# Use cached files (faster processing)
shorts-creator -v content.mp4 -nr
# Process with custom settings and debug mode
shorts-creator -v podcast.mp4 -s 6 -sd 45 -d 1800 --debug
# Use specific video effects strategy
shorts-creator -v demo.mp4 --strategy basic --debugThe tool creates the following directory structure:
shorts-creator/ # Output directory
βββ extracted_audio.mp3 # Extracted audio from input video
βββ speech.json # Transcription with precise timestamps
βββ shorts.json # AI analysis with metadata
βββ captions_0.ass # Generated captions for each short
βββ captions_1.ass
βββ short_0.mp4 # Generated shorts (ready for upload)
βββ short_1.mp4
βββ ...
Note: The poc/ directory contains proof-of-concept experiments and research code, not production functionality.
You can use different AI models by setting environment variables:
# Use OpenAI directly
YOUTUBE_SHORTS_OPENAI_BASE_URL=https://api.openai.com/v1
YOUTUBE_SHORTS_MODEL_NAME=gpt-4o-mini
# Use local models (if compatible with OpenAI API)
YOUTUBE_SHORTS_OPENAI_BASE_URL=http://localhost:1234/v1The following settings control video processing quality:
- Duration Requirements: Minimum duration enforced (can be 20-30% longer, never shorter)
- Speed Factor:
1.35(35% faster playback while preserving pitch) - Audio Standards:
-14 LUFSloudness with-1 dBFSpeak limiting - Video Quality: H.264 High profile, optimized bitrate, 1080x1920 resolution
- Text Overlays: Auto-generated titles and subtitle captions (ASS format)
- Whisper Model:
mediumorlargefor high-accuracy transcription - Video Effects: Configurable strategies (basic effects pipeline included)
The current BASIC strategy includes:
- Audio Normalization - YouTube-standard loudness (-14 LUFS) and peak limiting (-1 dBFS)
- Format Conversion - Smart 9:16 aspect ratio with intelligent content-aware cropping
- Text Overlays - AI-generated titles positioned at top of frame
- Caption Generation - Automatic subtitle creation with precise timing (ASS format)
- Visual Effects - Blur transitions and speed adjustments with pitch preservation
- Professional Encoding - Optimized H.264 output for mobile consumption
Additional strategies can be implemented by extending the VideoEffectsStrategy enum.
- FFmpeg not found: Install FFmpeg and ensure it's in your PATH
- API key errors: Check your
.envfile hasYOUTUBE_SHORTS_OPENAI_API_KEY - GPU/CUDA issues: The tool uses CPU-only processing by default for compatibility
- Font rendering: Built-in fonts are included, no system fonts required
- Use
-dto limit processing time for very long videos - Smaller short durations (
-sd) process faster - Consider using faster models for development/testing
This project is a proof-of-concept for educational and research purposes.