Running the Tool
The AI YouTube Shorts Generator supports multiple input methods and execution modes to fit your workflow.Interactive Mode
Run without arguments to enter interactive mode:Command-Line Mode
Pass the video source directly as an argument:The tool automatically detects whether the input is a local file path or YouTube URL by checking if the file exists on disk.
Resolution Selection
When downloading from YouTube, you’ll see available video streams with a 5-second auto-select timeout:The resolution selection uses a 5-second timeout implemented with
select.select() in Components/YoutubeDownloader.py:32.Interactive Approval Workflow
After the AI selects a highlight segment, you can review and approve it:Approval Options
Approve and Continue
Approve and Continue
Press Enter or y to accept the selected segment and proceed with video generation.
Regenerate Selection
Regenerate Selection
Press r to have the AI select a different 2-minute segment. You can regenerate multiple times until you’re satisfied.
Regeneration calls the GPT-4o-mini API again with
temperature=1.0 for varied results.Cancel Processing
Cancel Processing
Press n to cancel the entire operation and exit.
Auto-Approve (Default)
Auto-Approve (Default)
Wait 15 seconds without input to automatically approve. Perfect for automation and batch processing.
The 15-second timeout is implemented with
select.select() in main.py:122.Processing Workflow
The tool follows this step-by-step process:Download or Load Video
- YouTube videos are downloaded to the
videos/directory - Local files are used directly from the provided path
- Session ID is generated for tracking:
session_id = str(uuid.uuid4())[:8]
Transcribe with Whisper
GPU-accelerated transcription extracts timestamped text segments. Approximately 30 seconds for a 5-minute video.
AI Highlight Selection
GPT-4o-mini analyzes the transcription to find the most engaging 2-minute segment based on criteria:
- Interesting or useful content
- Surprising or controversial topics
- Thought-provoking ideas
- Complete sentences only
Interactive Approval
Review the selected segment with 15-second auto-approve timeout (skipped in batch mode).
Smart Cropping
Converts to 9:16 vertical format:
- Face videos: Static face-centered crop (no jerky movement)
- Screen recordings: Half-width display with smooth motion tracking (1 shift/second max)
temp_cropped_{session_id}.mp4Add Subtitles
Burns Franklin Gothic captions with blue text (Font size scales dynamically:
#2699ff) and black outline into the video:int(video.h * 0.065)- 1080p → 70px
- 720p → 47px
Output Files
Final videos are saved with slugified, descriptive filenames:Filename Components
- Title Slugification
- Session ID
- Output Resolution
The video title is cleaned and normalized:
- Converted to lowercase
- Spaces and underscores replaced with hyphens
- Invalid characters removed:
< > : " / \ | ? * [ ] - Multiple consecutive hyphens collapsed
- Trimmed to 80 characters max
"My Awesome Video!" → "my-awesome-video"Implementation in main.py:46-58:Example Outputs
All output files are saved in the current working directory unless running in Docker (then in
/app/output).Session IDs and Concurrent Execution
Each run generates a unique session ID for isolated processing:- No file conflicts: Each session has unique temp files
- Parallel processing: Run multiple videos simultaneously
- Output traceability: Session ID in filename shows which run created each video
- Easy debugging: Logs can be correlated by session ID
main.py:13 for session ID generation:
