HourGlass is a flexible and robust webcam timelapse system that automatically downloads images from any webcam URL, generates time-lapse videos from these images, and optionally adds soundtracks. The system supports multiple concurrent projects, features enhanced reliability, performance monitoring, and intelligent error handling. It runs continuously, capturing images at configurable intervals, with advanced session recovery and exponential backoff for maximum uptime.
- Multi-Project Support: Manage multiple timelapse projects from a single installation
- Automated Image Downloads: Downloads images from any configured webcam URL
- MJPEG Stream Support: Extracts frames from MJPEG video streams
- Duplicate Avoidance: Uses SHA-256 hashing to prevent saving duplicate images
- Time-Lapse Video Creation: Generates high-quality time-lapse videos from collected images
- Audio Track Addition: Adds dynamic soundtracks to time-lapse videos using Pixabay
- Even Audio Distribution: Songs split evenly across video with 5-second crossfades
- Song History Tracking: 180-day history prevents song repetition across videos
- TTS Intro: Random voice selection from Edge TTS (free) and Google Cloud TTS
- Robust Error Handling: Exponential backoff and automatic session recovery
- Health Monitoring: Real-time system monitoring with alerts for disk space, memory, CPU, and network
- Fast Image Validation: 5-10x faster image processing using optimized validation
- Memory Management: Prevents out-of-memory crashes with intelligent cleanup and chunked processing
- Performance Metrics: Comprehensive logging and performance tracking
- Log Rotation: Automatic log file management preventing huge log files
- Configuration Validation: Startup validation of settings and system health
- Timezone Support: Automatic timezone handling for remote webcams
- tmux Integration: Run captures in background with easy monitoring
- Ubuntu
- Fedora
- Debian
- macOS
- Python 3.12 (specifically - newer versions may have compatibility issues with dependencies)
- tmux (for background operation)
- ffmpeg (for video/audio processing)
- Additional system monitoring capabilities (automatically installed)
- Google Cloud TTS: For high-quality text-to-speech intros. See GOOGLE_TTS_SETUP.md for setup instructions.
- Edge TTS: Free alternative that works out of the box with no API key required. The system randomly selects between Edge and Google (if configured) for voice variety.
# Install dependencies
bash setup.sh
# Configure your first project
python main.py
# Or directly with project name:
python main.py <project_name># Start capture for a project
./hourglass.sh <project_name>
# Or run directly with Python
python main.py <project_name>
# Run with time bypass (for testing)
python main.py <project_name> --no-time-check# Generate video from existing images
python main.py <project_name> --movie# Generate test images and run full video compilation without real captures
python main.py <project_name> --test-compileHourGlass/
├── main.py # Main entry point
├── lib/ # Library modules
│ ├── timelapse_core.py # Core functionality
│ ├── timelapse_config.py # Configuration management
│ ├── timelapse_setup.py # Project setup wizard
│ ├── timelapse_loop.py # Main capture loop
│ ├── timelapse_validator.py # Image validation
│ ├── timelapse_upload.py # YouTube upload
│ ├── config_validator.py # Config validation
│ ├── health_monitor.py # System health monitoring
│ ├── memory_optimizer.py # Memory management
│ └── ...
├── configs/ # Project configurations
│ ├── project1.json
│ ├── project2.json
│ └── ...
├── instructions/ # Generated setup instructions
│ ├── project1_instructions.txt
│ └── ...
└── ~/HourGlass/<project>/ # Project data (configurable)
├── images/
├── video/
├── audio/
└── logging/
Each project has its own configuration file in configs/<project_name>.json. Key settings include:
- Webcam URLs: Direct image URL or MJPEG stream
- Capture interval: Time between image captures
- Sunrise/sunset times: Automatic or manual scheduling
- Timezone offset: For remote webcam locations
- Alert settings: ntfy.sh integration for notifications
- Audio settings: Background music configuration
ls configs/python timelapse_setup.py
# Select "Create new project"python timelapse_setup.py
# Select the project to updateHourGlass automatically creates tmux sessions for background operation:
# Attach to running session
tmux attach -t hourglass-<project_name>
# List all sessions
tmux list-sessions
# Kill a session
tmux kill-session -t hourglass-<project_name>Each project's instructions file contains customized cron entries. Example:
# Start capture at sunrise
0 6 * * * cd /path/to/HourGlass && ./hourglass.sh project_name
# Stop capture after sunset
0 20 * * * pkill -f 'python main.py project_name'python main.py <project_name> --healthpython main.py <project_name> --validatepython main.py <project_name> --debug- No project found: Ensure the project config exists in
configs/ - Session creation failed: Check USER_AGENTS and PROXIES in config
- Images not saving: Verify the webcam URL is accessible
- MJPEG streams: The system automatically detects and handles MJPEG streams
Check project-specific logs:
tail -f ~/HourGlass/<project_name>/logging/timelapse.log- Optimized for long-running captures with automatic recovery
- Memory-efficient processing for large image collections
- Automatic cleanup of temporary files
- Intelligent backoff for network failures
Contributions are welcome! Please ensure any changes maintain backward compatibility with existing project configurations.
[Your License Here]