YouTube to HeyGen Avatar Video
Converts YouTube videos into 60-second vertical avatar videos using your HeyGen AI clone. Analyzes the video with Gemini AI, rewrites as an Alex Hormozi-style script, generates a social media caption, and creates the avatar video.
What It Does
- Sends YouTube URL to Gemini 2.0 Flash for direct video analysis
- Generates a ~180-word Alex Hormozi-style script (≈60 seconds of speaking)
- Creates a social media caption with SEO keywords and hashtags
- Sends script to HeyGen API for avatar video generation (1080x1920 vertical)
- Polls for completion and stores video URL in
gemini_video_agentdatabase table
How to Run
# Generate avatar video from YouTube
python3 skills/youtube-to-heygen-video/scripts/youtube_to_heygen_video.py "https://www.youtube.com/watch?v=VIDEO_ID"
# Start generation without waiting for completion
python3 skills/youtube-to-heygen-video/scripts/youtube_to_heygen_video.py "https://www.youtube.com/watch?v=VIDEO_ID" --no-wait
Configuration
Environment Variables
GEMINI_API_KEY=xxx
HEYGEN_API_KEY=xxx
HEYGEN_AVATAR_ID=xxx # Your avatar clone ID
HEYGEN_VOICE_ID=xxx # Your voice clone ID
DATABASE_URL=postgresql://...
Dependencies
pip install google-generativeai requests psycopg2-binary python-dotenv
Script Format (Alex Hormozi Style)
- Hook (3-5 sec): Bold/contrarian statement, pattern interrupt
- Body (60-70%): ONE core concept, 2-3 supporting points, short punchy sentences
- Close (15-20 sec): Restate transformation, create urgency, comment CTA
Constraints
- ~180 words (≈60 seconds)
- Max 4000 characters (HeyGen limit)
- No
\nliterals (causes unnatural pauses) - No markdown formatting
HeyGen Settings
| Setting | Value |
|---|---|
| Dimension | 1080x1920 (vertical/shorts) |
| Background | #000000 (black) |
| Avatar Style | normal |
| Voice Emotion | Excited |
| Generation Time | 2-5 minutes |
Important Notes
- Gemini: Can analyze YouTube URLs directly — no need to download videos
- Script Length: Keep under 4000 characters or HeyGen truncates
- Generation Time: 2-5 minutes; script polls every 10 seconds with 10-minute timeout
- Newlines: Strip all
\nliterals — they cause unnatural pauses in avatar speech - Database: Stores video_id immediately, updates with URL after completion
Scripts
| File | Purpose |
|---|---|
youtube_to_heygen_video.py |
Main short-form avatar video generator |