A fully automated system for creating and posting AI-generated story videos to YouTube Shorts every 6 hours.
- AI Story Generation: Uses OpenAI GPT-4 to create unique stories (horror, romance, action, wholesome)
- Natural Voice Narration: Converts stories to speech using ElevenLabs TTS
- Professional Video Composition: Overlays narration on gameplay footage with subtitles
- Automated YouTube Upload: Posts videos every 6 hours with optimized titles and descriptions
- Analytics Tracking: Monitors performance and identifies trending story types
- Background Music: Adds royalty-free background music for enhanced engagement
- Cloud-Ready: Designed for deployment on cloud platforms (AWS, GCP, Azure)
┌─────────────────┐
│ Story Generator │ (OpenAI GPT-4)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Voice Generator │ (ElevenLabs TTS)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Video Composer │ (FFmpeg)
└────────┬────────┘
│
▼
┌─────────────────┐
│ YouTube Uploader│ (YouTube Data API)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Analytics │ (Performance Tracking)
└─────────────────┘
- Node.js 18+ and npm
- FFmpeg (installed automatically via ffmpeg-static)
- OpenAI API key
- ElevenLabs API key
- YouTube Data API credentials
- (Optional) AWS S3 for asset storage
- (Optional) Pexels/Pixabay API keys for background videos
npm installCopy the example environment file:
cp .env.example .envEdit .env and add your API keys:
# Required
OPENAI_API_KEY=your_openai_key
ELEVENLABS_API_KEY=your_elevenlabs_key
YOUTUBE_CLIENT_ID=your_youtube_client_id
YOUTUBE_CLIENT_SECRET=your_youtube_client_secret
# Optional but recommended
PEXELS_API_KEY=your_pexels_key
PIXABAY_API_KEY=your_pixabay_keynode src/scripts/setupYouTube.jsFollow the prompts to authorize the application and get your refresh token.
Create directories and add your assets:
mkdir -p assets/videos
mkdir -p assets/musicAdd royalty-free gameplay videos to assets/videos/ and background music to assets/music/.
Optionally organize by story type:
assets/
├── videos/
│ ├── horror/
│ ├── romantic/
│ ├── action/
│ └── wholesome/
└── music/
└── ambient-music.mp3
npm startThis starts the scheduler that will:
- Generate a new video every 6 hours
- Upload to YouTube automatically
- Track analytics daily
Generate a story:
npm run generate-story
# Or specify type:
node src/scripts/generateStory.js horrorTest the complete pipeline (without uploading):
node src/scripts/testPipeline.jsEdit src/config/config.js or use environment variables:
UPLOAD_INTERVAL_HOURS: Change posting frequency (default: 6)VIDEO_WIDTH/VIDEO_HEIGHT: Video dimensions (default: 1080x1920)STORY_DURATION_SECONDS: Target story length (default: 50)RUN_ON_STARTUP: Run immediately on start (default: false)CLEANUP_FILES: Delete files after upload (default: false)
youtube-shorts-automation/
├── src/
│ ├── config/
│ │ └── config.js # Configuration management
│ ├── services/
│ │ ├── storyGenerator.js # AI story generation
│ │ ├── voiceoverGenerator.js # TTS voice generation
│ │ ├── backgroundManager.js # Video background handling
│ │ ├── videoComposer.js # Video composition with FFmpeg
│ │ ├── youtubeUploader.js # YouTube API integration
│ │ ├── contentPipeline.js # Main pipeline orchestration
│ │ └── analyticsTracker.js # Performance tracking
│ ├── utils/
│ │ └── logger.js # Winston logging
│ ├── scripts/
│ │ ├── generateStory.js # Test story generation
│ │ ├── testPipeline.js # Test full pipeline
│ │ └── setupYouTube.js # YouTube OAuth setup
│ └── index.js # Main entry point with scheduler
├── assets/
│ ├── videos/ # Background videos
│ └── music/ # Background music
├── output/ # Generated videos
├── logs/ # Application logs
├── .env # Environment configuration
├── .env.example # Example environment file
├── package.json
└── README.md
- Go to https://platform.openai.com/api-keys
- Create a new API key
- Add to
.envasOPENAI_API_KEY
- Sign up at https://elevenlabs.io
- Go to Profile Settings → API Key
- Add to
.envasELEVENLABS_API_KEY - Get voice IDs from Voice Library and add as
ELEVENLABS_VOICE_ID
- Go to https://console.cloud.google.com
- Create a new project
- Enable YouTube Data API v3
- Create OAuth 2.0 credentials (Desktop app)
- Add Client ID and Secret to
.env - Run
node src/scripts/setupYouTube.jsto get refresh token
- Sign up at https://www.pexels.com/api
- Get API key and add to
.env
- Sign up at https://pixabay.com/api
- Get API key and add to
.env
- Launch an EC2 instance (Ubuntu 20.04+)
- Install Node.js and dependencies
- Clone repository and configure
- Use PM2 for process management:
npm install -g pm2
pm2 start src/index.js --name youtube-automation
pm2 save
pm2 startup# Build and deploy
gcloud run deploy youtube-automation \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticatedFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
CMD ["npm", "start"]The system automatically tracks:
- Video views, likes, and comments
- Performance by story type
- Channel growth metrics
- Best performing content
Generate a performance report:
const analyticsTracker = require('./src/services/analyticsTracker');
const report = analyticsTracker.generateReport();
console.log(report);View logs:
# Combined logs
tail -f logs/combined.log
# Error logs only
tail -f logs/error.log
# Upload logs
tail -f logs/uploads.log- Ensure FFmpeg is properly installed
- Check video/audio file formats are compatible
- Verify file paths don't contain special characters
- Verify OAuth tokens are valid
- Check YouTube API quota limits
- Ensure video meets YouTube's requirements (duration, format, etc.)
- Check OpenAI API key and quota
- Verify API model access (GPT-4)
- Review rate limits
- Verify ElevenLabs API key
- Check character quota
- Ensure voice ID is valid
Monthly costs for 4 videos/day (120 videos/month):
- OpenAI GPT-4: ~$6-12 (depending on token usage)
- ElevenLabs: ~$5-22 (Creator tier recommended)
- YouTube API: Free (within quota limits)
- Cloud hosting: ~$5-20 (depending on provider)
- Total: $16-54/month
- Only use royalty-free or properly licensed content
- Comply with YouTube's Terms of Service
- Follow monetization policies
- Disclose AI-generated content when required
- Respect copyright and intellectual property laws
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - See LICENSE file for details
For issues and questions:
- Check the logs in
logs/directory - Review the troubleshooting section
- Open an issue on GitHub
- Multi-language support
- Custom voice training
- Advanced analytics dashboard
- A/B testing for titles/thumbnails
- Integration with more video platforms
- Automated thumbnail generation
- Content moderation and safety checks
- Advanced scheduling options
- OpenAI for GPT-4 API
- ElevenLabs for TTS API
- FFmpeg for video processing
- YouTube Data API
- All open-source contributors
Note: This is an automated content creation tool. Always review and comply with platform policies and local regulations.