π¬ AI Video Generator - Free Hailuo Clone
A free, open-source AI-powered video generation application that creates videos from text prompts using Hugging Face's Zeroscope model.
β¨ Features
- π¨ Text-to-Video Generation: Create videos from simple text descriptions
- π― Modern UI: Beautiful, responsive interface with gradient design
- π₯ Video Download: Download generated videos directly to your device
- β‘ Real-time Status: Live feedback with loading indicators and status messages
- π Input Validation: Robust validation and error handling
- π Health Monitoring: Server health check endpoint
- π Example Prompts: Quick-start with pre-made prompt examples
- π Character Counter: Track your prompt length in real-time
π Quick Start
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- Modern web browser (Chrome, Firefox, Safari, or Edge)
Installation
Clone or navigate to the project directory:
cd /Users/sravyalu/VideoAI/hailuo-cloneCreate and activate a virtual environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtSet up environment variables:
cp .env.example .envEdit
.envfile if you need to customize settings:HF_SPACE_URL=https://cerspense-zeroscope-v2-xl.hf.space/ FLASK_PORT=5000 FLASK_DEBUG=False
Running the Application
Start the backend server:
python backend.pyYou should see:
INFO - Starting Flask server on port 5000 (debug=False) INFO - Successfully connected to Hugging Face SpaceOpen the frontend:
- Simply open
index.htmlin your web browser - Or use a local server:
Then visit:python -m http.server 8000http://localhost:8000
- Simply open
Generate your first video:
- Enter a text prompt (e.g., "A dog running in a park")
- Click "Generate Video"
- Wait 10-60 seconds for the AI to create your video
- Watch and download your generated video!
π Project Structure
hailuo-clone/
βββ backend.py # Flask backend server
βββ index.html # Frontend UI
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ README.md # This file
βββ app.log # Application logs (created at runtime)
π οΈ Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
HF_SPACE_URL |
https://cerspense-zeroscope-v2-xl.hf.space/ |
Hugging Face Space URL |
FLASK_PORT |
5000 |
Backend server port |
FLASK_DEBUG |
False |
Enable/disable debug mode |
Prompt Limits
- Minimum length: 3 characters
- Maximum length: 500 characters
π§ API Endpoints
Health Check
GET /health
Returns server health status and client initialization state.
Response:
{
"status": "healthy",
"timestamp": "2025-10-02T17:38:51-07:00",
"client_initialized": true
}
Generate Video
POST /generate-video
Content-Type: application/json
Request Body:
{
"prompt": "A dog running in a park"
}
Success Response (200):
{
"video_url": "https://...",
"prompt": "A dog running in a park",
"timestamp": "2025-10-02T17:38:51-07:00"
}
Error Response (400/500/503/504):
{
"error": "Error message here"
}
π Troubleshooting
Backend Issues
Problem: ModuleNotFoundError: No module named 'flask'
- Solution: Install dependencies:
pip install -r requirements.txt
Problem: Failed to initialize Gradio client
- Solution: Check your internet connection and verify the Hugging Face Space URL is correct
Problem: Port 5000 already in use
- Solution: Change the port in
.envfile or stop the process using port 5000
Frontend Issues
Problem: "Cannot connect to server" error
- Solution: Ensure the backend is running on port 5000
Problem: Video doesn't play
- Solution: Check browser console for errors. Some browsers block autoplay.
Problem: CORS errors
- Solution: The backend has CORS enabled. Make sure you're using the correct URL.
π Logging
Application logs are saved to app.log in the project directory. Logs include:
- Server startup/shutdown events
- Video generation requests
- Errors and exceptions
- Client connection status
View logs in real-time:
tail -f app.log
π Security Notes
- Never commit
.envfile to version control - Don't run in debug mode in production (
FLASK_DEBUG=False) - Consider adding rate limiting for production use
- Validate and sanitize all user inputs (already implemented)
π Production Deployment
For production deployment, consider:
Use a production WSGI server (e.g., Gunicorn):
pip install gunicorn gunicorn -w 4 -b 0.0.0.0:5000 backend:appSet up a reverse proxy (e.g., Nginx)
Enable HTTPS with SSL certificates
Add rate limiting to prevent abuse
Set up monitoring and alerting
Use environment variables for sensitive configuration
π€ Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
π License
This project is open source and available under the MIT License.
π Acknowledgments
- Built with Flask
- Uses Gradio Client for Hugging Face integration
- Video generation powered by Zeroscope
π Support
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Review the logs in
app.log - Open an issue on the project repository
Made with β€οΈ for the AI community