Skip to main content

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:
./run.sh
You’ll be prompted to enter a YouTube URL or local file path:
Enter YouTube video URL or local video file path: 

Command-Line Mode

Pass the video source directly as an argument:
./run.sh "https://youtu.be/VIDEO_ID"
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:
Available video streams:
  0. Resolution: 1080p, Size: 45.2 MB, Type: Adaptive
  1. Resolution: 720p, Size: 28.1 MB, Type: Adaptive
  2. Resolution: 480p, Size: 15.3 MB, Type: Adaptive

Select resolution number (0-2) or wait 5s for auto-select...
Auto-selecting highest quality in 5 seconds...
1

Enter a number

Type 0, 1, or 2 to immediately select that resolution
2

Wait for auto-select

Wait 5 seconds to automatically select the highest quality (1080p)
3

Fallback behavior

Invalid input defaults to highest quality
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:
============================================================
SELECTED SEGMENT DETAILS:
Time: 68s - 187s (119s duration)
============================================================

Options:
  [Enter/y] Approve and continue
  [r] Regenerate selection
  [n] Cancel

Auto-approving in 15 seconds if no input...

Approval Options

Press Enter or y to accept the selected segment and proceed with video generation.
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.
Press n to cancel the entire operation and exit.
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:
1

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]
2

Extract Audio

Converts video to WAV format for transcription:
audio_{session_id}.wav
3

Transcribe with Whisper

GPU-accelerated transcription extracts timestamped text segments. Approximately 30 seconds for a 5-minute video.
4

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
5

Interactive Approval

Review the selected segment with 15-second auto-approve timeout (skipped in batch mode).
6

Extract Clip

Creates temporary clip from the selected timeframe:
temp_clip_{session_id}.mp4
7

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)
Output: temp_cropped_{session_id}.mp4
8

Add Subtitles

Burns Franklin Gothic captions with blue text (#2699ff) and black outline into the video:
temp_subtitled_{session_id}.mp4
Font size scales dynamically: int(video.h * 0.065)
  • 1080p → 70px
  • 720p → 47px
9

Combine Audio

Merges audio track with the final video using FFmpeg.
10

Cleanup

Automatically removes all temporary files:
  • audio_{session_id}.wav
  • temp_clip_{session_id}.mp4
  • temp_cropped_{session_id}.mp4
  • temp_subtitled_{session_id}.mp4

Output Files

Final videos are saved with slugified, descriptive filenames:
{video-title}_{session-id}_short.mp4

Filename Components

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
Example: "My Awesome Video!""my-awesome-video"Implementation in main.py:46-58:
def clean_filename(title):
    cleaned = title.lower()
    cleaned = re.sub(r'[<>:"/\\|?*\[\]]', '', cleaned)
    cleaned = re.sub(r'[\s_]+', '-', cleaned)
    cleaned = re.sub(r'-+', '-', cleaned)
    cleaned = cleaned.strip('-')
    return cleaned[:80]

Example Outputs

how-to-build-a-saas-in-30-days_3f8a9b12_short.mp4
ai-coding-tips-for-beginners_7c2d4e56_short.mp4
my-startup-journey-lessons-learned_9a1b3c5d_short.mp4
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:
./run.sh "https://youtu.be/VIDEO1" &
./run.sh "https://youtu.be/VIDEO2" &
./run.sh "/path/to/video3.mp4" &
All instances share the same videos/ directory for downloaded content, but temporary files are isolated by session ID.
Benefits:
  • 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
See main.py:13 for session ID generation:
session_id = str(uuid.uuid4())[:8]
print(f"Session ID: {session_id}")

Build docs developers (and LLMs) love