Automated News Video Generator for YouTube Shorts
FlashVideoBot is a comprehensive Python application that automatically fetches the latest news from multiple sources and creates engaging, eye-catching videos optimized for YouTube-style retention. The bot generates short (15-30 second) videos with dynamic text animations, visual effects, and professional audio narration.
- Multiple Sources: NewsAPI, RSS feeds from major news outlets
- Smart Filtering: Removes duplicates and low-quality content
- Category Support: Technology, business, health, sports, and more
- Caching: Intelligent caching to avoid duplicate API calls
- NLP-Powered: Uses transformers, sumy, and NLTK for intelligent summarization
- Engaging Hooks: Generates attention-grabbing opening statements
- Key Points: Extracts main points for bullet-point presentation
- Readability: Optimizes text for video consumption
- YouTube Shorts Format: Optimized 1080x1920 vertical videos
- Dynamic Text Effects: Typewriter, pulse, slide, and bounce animations
- Professional Transitions: Fade, zoom, and slide effects between segments
- Visual Effects: Ken Burns effect, vignette, progress bars
- Retention Optimization: Fast pacing with strategic visual hooks
- Text-to-Speech: Support for gTTS and pyttsx3 engines
- Background Music: Automatic music selection based on content sentiment
- Natural Pacing: Strategic pauses and emphasis for better engagement
- Audio Mixing: Balanced narration and background audio
- Stock Images: Integration with Unsplash and Pixabay APIs
- Smart Keywords: Automatic keyword extraction for relevant visuals
- Image Processing: Automatic resizing, enhancement, and optimization
- Fallback System: Ensures videos always have appropriate visuals
- Python: 3.8 or higher
- Operating System: Windows, macOS, or Linux
- Memory: 4GB RAM minimum (8GB recommended)
- Storage: 2GB free space for cache and output files
- FFmpeg: For advanced audio/video processing (recommended)
- ImageMagick: For enhanced image processing
git clone https://github.com/yourusername/FlashVideoBot.git
cd FlashVideoBot
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
pip install -r requirements.txt
python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords'); nltk.download('wordnet')"
- Windows: Download from https://ffmpeg.org/download.html
- macOS:
brew install ffmpeg
- Linux:
sudo apt install ffmpeg
(Ubuntu/Debian)
For convenience, you can run the setup script for your platform:
# On Windows:
.\setup_windows.ps1
# On macOS/Linux:
chmod +x setup_unix.sh
./setup_unix.sh
Copy the example configuration file and add your API keys:
cp config/config.example.yaml config/config_local.yaml
Edit config/config_local.yaml
with your API keys:
news:
# Get free key at https://newsapi.org
newsapi_key: "YOUR_NEWS_API_KEY"
# Get free key at https://pixabay.com/api/docs/
pixabay_key: "YOUR_PIXABAY_API_KEY"
# Get free key at https://unsplash.com/developers
unsplash_key: "YOUR_UNSPLASH_ACCESS_KEY"
For detailed instructions on how to obtain all the required API keys:
- Read our comprehensive API Setup Guide
- The guide covers NewsAPI, Unsplash, Pixabay, and other services
- Free tier options are available for all required APIs
You can test if all your API keys are working correctly by running:
python test_apis.py
This will check all configured APIs and report their status.
You can also set API keys via environment variables:
export NEWSAPI_KEY="YOUR_NEWS_API_KEY"
export UNSPLASH_KEY="YOUR_UNSPLASH_ACCESS_KEY"
export PIXABAY_KEY="YOUR_PIXABAY_API_KEY"
Setting | Description | Default |
---|---|---|
news.max_articles |
Number of articles to process | 5 |
video.duration |
Maximum video length (seconds) | 30 |
video.width |
Video width (pixels) | 1080 |
video.height |
Video height (pixels) | 1920 |
audio.tts.engine |
TTS engine (gtts/pyttsx3) | gtts |
audio.music.enabled |
Enable background music | true |
# Activate virtual environment
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
# Run the bot
python main.py
# Use custom config file
python main.py --config custom_config.yaml
# Set maximum articles
python main.py --max-articles 10
# Disable background music
python main.py --no-music
from main import FlashVideoBot
import asyncio
async def create_videos():
bot = FlashVideoBot()
await bot.run()
# Run the bot
asyncio.run(create_videos())
FlashVideoBot/
โโโ main.py # Main application entry point
โโโ requirements.txt # Python dependencies
โโโ config/
โ โโโ config.yaml # Configuration template
โโโ src/
โ โโโ config_manager.py # Configuration handling
โ โโโ news_fetcher.py # News source integration
โ โโโ text_summarizer.py # NLP and summarization
โ โโโ video_creator.py # Video generation with effects
โ โโโ audio_manager.py # TTS and audio processing
โ โโโ image_manager.py # Image fetching and processing
โ โโโ utils/
โ โโโ logger.py # Logging utilities
โโโ assets/
โ โโโ fonts/ # Custom fonts (optional)
โ โโโ music/ # Background music files
โ โโโ temp/ # Temporary files and cache
โโโ videos/ # Generated video output
โโโ logs/ # Application logs
- News Fetching: Retrieves latest articles from configured sources
- Content Analysis: Extracts keywords and generates summaries
- Hook Creation: Creates attention-grabbing opening statements
- Visual Assets: Downloads relevant images based on content
- Audio Generation: Creates TTS narration with natural pacing
- Video Assembly: Combines all elements with dynamic effects
- Optimization: Applies retention-focused enhancements
- Place font files (.ttf, .otf) in
assets/fonts/
- Update configuration to reference new fonts
- Place audio files (.mp3, .wav) in
assets/music/
- Name files with mood keywords (e.g., "upbeat_news.mp3", "dramatic_breaking.mp3")
Modify src/video_creator.py
to add new:
- Text animations
- Transition effects
- Visual filters
- Color schemes
Import Errors
# Install missing packages
pip install -r requirements.txt
# Update packages
pip install --upgrade -r requirements.txt
API Rate Limits
- Ensure API keys are valid and have sufficient quota
- Check API usage limits on provider websites
- Implement rate limiting in configuration
Video Generation Fails
- Check FFmpeg installation
- Verify sufficient disk space
- Review logs for specific error messages
Poor Video Quality
- Increase image resolution settings
- Use higher quality TTS engine
- Add better background music
Memory Usage
- Reduce
news.max_articles
for lower memory usage - Enable image caching
- Clear temp files regularly
Speed Improvements
- Use local TTS engine (pyttsx3) instead of gTTS
- Increase
performance.max_workers
- Cache images and audio files
Generated videos include:
- File Format: MP4 (H.264/AAC)
- Resolution: 1080x1920 (YouTube Shorts optimized)
- Duration: 15-30 seconds
- Naming:
news_video_YYYYMMDD_HHMMSS.mp4
- Location:
videos/
directory
Comprehensive documentation is available in the docs/
directory:
- Quick Start Guide - Get up and running quickly
- API Setup Guide - How to obtain all required API keys
- Configuration Options - Detailed configuration settings
- Full Documentation Index - Complete documentation reference
Application logs are saved to:
- Main Log:
logs/flashvideobot.log
- Error Log:
logs/errors.log
- Rotation: Logs rotate automatically to prevent large files
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- MoviePy for video processing
- gTTS for text-to-speech functionality
- NLTK for natural language processing
- Pillow for image processing
- Unsplash and Pixabay for image APIs
- NewsAPI for news content
- Issues: Report bugs on GitHub Issues
- Discussions: Join discussions on GitHub Discussions
- Documentation: Full docs at docs/
- Real-time news monitoring
- Multiple video formats (landscape, square)
- Advanced AI voice generation
- Social media platform integration
- Custom branding and overlays
- Analytics and performance tracking
- Multi-language support
- Live streaming integration
Made with โค๏ธ by the FlashVideoBot team for creators who want to automate engaging news content