A modern Django-based video streaming application that provides HLS (HTTP Live Streaming) video playback with automatic video conversion, thumbnail generation, and a responsive web interface.deo Streaming App
- Video Upload & Management: Upload videos in various formats with automatic conversion
- HLS Streaming: Adaptive bitrate streaming using HLS protocol for optimal viewing experience
- Automatic Processing:
- Video conversion to HLS format using FFmpeg
- Thumbnail generation from video frames
- Duration extraction
- Responsive UI: Modern, mobile-friendly interface with Video.js player
- Admin Interface: Django admin integration for video management
- Docker Support: Containerized deployment with Docker
- Dev Container: VS Code dev container support for development
- Backend: Django 5.2.4
- Database: SQLite (development) / PostgreSQL (production ready)
- Video Processing: FFmpeg
- Frontend: HTML5, CSS3, JavaScript, Bootstrap
- Video Player: Video.js with HLS support
- Image Processing: Pillow
- Containerization: Docker
video-streaming-app/
โโโ src/
โ โโโ pomegranate/ # Django project settings
โ โโโ video/ # Main video app
โ โ โโโ models.py # Video model
โ โ โโโ views.py # Video views
โ โ โโโ signals.py # Post-save processing
โ โ โโโ utils/ # Video processing utilities
โ โ โโโ convert.py # HLS conversion
โ โ โโโ thumbnail.py # Thumbnail generation
โ โโโ templates/ # HTML templates
โ โโโ media/ # User uploads & processed files
โโโ requirements.txt # Python dependencies
โโโ Dockerfile # Docker configuration
โโโ dev-compose.yml # Development docker-compose
- Python 3.10+
- FFmpeg
- Docker (optional)
-
Clone the repository
git clone https://github.com/msinamsina/video-streaming-app.git cd video-streaming-app
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Install FFmpeg
- Ubuntu/Debian:
sudo apt update && sudo apt install ffmpeg
- macOS:
brew install ffmpeg
- Windows: Download from FFmpeg official website
- Ubuntu/Debian:
-
Run migrations
cd src python manage.py migrate
-
Create superuser (optional)
python manage.py createsuperuser
-
Start development server
python manage.py runserver
-
Access the application
- Main app: http://localhost:8000
- Admin panel: http://localhost:8000/admin
-
Using Docker Compose
docker-compose -f dev-compose.yml up --build
-
Access the application
- Application: http://localhost:8000
- Access the Django admin panel at
/admin
- Navigate to Videos section
- Click "Add Video" and upload your video file
- The system will automatically:
- Convert the video to HLS format
- Generate a thumbnail
- Extract video duration
- Create streaming segments
- Visit the main page to see all uploaded videos
- Click on any video to open the video player
- The player supports:
- HLS adaptive streaming
- Full-screen mode
- Playback controls
- Mobile-responsive design
Key settings in src/pomegranate/settings.py
:
# Media files configuration
MEDIA_URL = "media/"
MEDIA_ROOT = BASE_DIR / "media"
# Video processing settings can be customized in:
# - src/video/utils/convert.py (HLS conversion parameters)
# - src/video/utils/thumbnail.py (thumbnail generation)
Customize video processing in src/video/utils/convert.py
:
- HLS Segment Duration: Default 10 seconds
- Video Codec: Copy (no re-encoding for faster processing)
- Audio Codec: Copy
- Hardware Acceleration: Auto-detected
GET /
- Video list pageGET /video/<id>/
- Video player pageGET /video/<id>/hls/
- HLS playlist endpointGET /media/videos/hls/<id>/
- HLS segments
-
FFmpeg not found
- Ensure FFmpeg is installed and available in PATH
- On Docker: FFmpeg is included in the container
-
Video upload fails
- Check file size limits in Django settings
- Verify media directory permissions
-
HLS streaming not working
- Ensure Video.js and HLS.js are properly loaded
- Check browser console for JavaScript errors
Enable debug mode in settings for detailed error messages:
DEBUG = True
- The current configuration uses
DEBUG = True
and a development secret key - For production deployment:
- Set
DEBUG = False
- Use a secure
SECRET_KEY
- Configure
ALLOWED_HOSTS
- Use a production database (PostgreSQL recommended)
- Set up proper media file serving (nginx, CDN)
- Set
Create a .env
file for production:
DEBUG=False
SECRET_KEY=your-secret-key-here
DATABASE_URL=postgresql://user:pass@localhost/dbname
ALLOWED_HOSTS=your-domain.com
-
Build production image:
docker build -t video-streaming-app .
-
Run with environment variables:
docker run -p 8000:8000 --env-file .env video-streaming-app
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make your changes and add tests
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- msinamsina - Initial work - GitHub
- Django - Web framework
- FFmpeg - Video processing
- Video.js - HTML5 video player
- Bootstrap - CSS framework
- Videos are processed asynchronously after upload
- HLS segments are generated for adaptive streaming
- Thumbnails are extracted at the 2-second mark
- Hardware acceleration is used when available
- Multiple video quality options
- User authentication and playlists
- Video analytics and statistics
- Subtitle support
- Live streaming capabilities
- CDN integration
- Advanced video player features