A web application that processes YouTube videos using FastAPI, Celery, and Next.js. This application allows users to input a YouTube URL, download the video, and process it with real-time progress tracking.
- YouTube video processing with progress tracking
- Real-time status updates
- Video preview and download functionality
- Containerized development and production environments
- Asynchronous task processing with Celery
- Modern UI with Tailwind CSS
- Error handling and validation
- Progress bar for download and processing status
- Automatic video player preview
- Next.js: React framework for production
- Tailwind CSS: Utility-first CSS framework
- React: UI library
- fetch API: For handling HTTP requests
- FastAPI: Modern Python web framework
- Celery: Distributed task queue
- Redis: Message broker and result backend
- yt-dlp: YouTube video downloader
- uvicorn: ASGI server
- Python 3.9+: Programming language
- Docker: Containerization
- Docker Compose: Multi-container orchestration
- Nginx: Production web server (optional)
- Docker and Docker Compose
- Node.js 16+ (for local frontend development)
- Python 3.9+ (for local backend development)
- Git
- Clone the repository:
git clone <repository-url>
cd youtube-video-processor- Create environment files:
# .env.development
REDIS_URL=redis://redis:6379/0
API_URL=http://localhost:8000- Start the development environment:
docker-compose up --buildThe application will be available at:
- Frontend: http://localhost:3456
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Create production environment files:
# .env.production
REDIS_URL=redis://redis:6379/0
API_URL=https://your-domain.com/api- Build and run for production:
docker-compose -f docker-compose.prod.yml up --build.
├── frontend/ # Next.js frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ │ └── VideoForm.jsx # Main video processing form
│ │ └── app/ # Next.js pages
│ ├── package.json
│ └── tailwind.config.js
├── backend/ # FastAPI backend application
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── tasks.py # Celery tasks
│ │ └── celeryconfig.py # Celery configuration
│ ├── Dockerfile # Development Dockerfile
│ ├── Dockerfile.prod # Production Dockerfile
│ └── requirements.txt
├── docker-compose.yml # Development compose file
└── docker-compose.prod.yml # Production compose file
POST /api/process-video
Start processing a YouTube video.
Request body:
{
"url": "https://youtube.com/watch?v=..."
}Response:
{
"job_id": "task-uuid-here"
}GET /api/task-status/{job_id}
Check the status of a processing task.
Response:
{
"status": "PROCESSING",
"progress": 45,
"result": {
"download_url": "http://..."
}
}Status values:
STARTING: Task is initializingPROCESSING: Task is in progressSUCCESS: Task completed successfullyERROR: Task failed
cd frontend
npm install
npm run devcd backend
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
pip install -r requirements.txt
uvicorn app.main:app --reloadcd backend
celery -A app.tasks worker --loglevel=infoFrontend:
NEXT_PUBLIC_API_URL: Backend API URL
Backend:
REDIS_URL: Redis connection URLCORS_ORIGINS: Allowed CORS originsMAX_WORKERS: Maximum Celery workers
The application handles various error cases:
- Invalid YouTube URLs
- Network connectivity issues
- Video processing failures
- Server errors
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Common issues and solutions:
-
Redis Connection Error
- Ensure Redis is running
- Check Redis URL configuration
-
Video Processing Fails
- Verify YouTube URL is valid
- Check network connectivity
- Ensure sufficient disk space
-
Docker Issues
- Run
docker-compose down -vto clean up - Rebuild containers with
docker-compose up --build
- Run