DTube is a local-first video streaming app built with FastAPI. It scans your configured folders, indexes supported video files, and serves a web interface for browsing, watching, liking, and commenting.
- Automatic local video indexing (
.mp4,.mkv,.webm,.mov) - Home page with search and sorting
- Dedicated watch page with sidebar recommendations
- HTTP range-based streaming (seek support)
- Video download endpoint
- Auto thumbnail generation (when
ffmpegis available) - View tracking
- Video like/unlike
- Nested comments and comment like/unlike
- SQLite-backed persistence (
data/dtube.db) - JSON metadata cache with migration support (
data/video_meta.json) - Basic security headers (CSP, X-Frame-Options, etc.)
- Python 3.10+
- FastAPI
- Uvicorn
- SQLAlchemy
- Jinja2
- SQLite
- Optional:
ffmpeg/ffprobe
DTube/
ββ app/
β ββ main.py # FastAPI app bootstrap
β ββ core/database.py # DB init + migration helpers
β ββ routes/video.py # Web routes + API endpoints
β ββ models/ # SQLAlchemy models
ββ templates/ # HTML templates
ββ static/ # CSS, JS, assets
ββ data/
β ββ dtube.db # SQLite database
β ββ video_meta.json # Video metadata cache
β ββ thumbnails/ # Generated thumbnails
β ββ transcoded/ # Reserved transcoded outputs
ββ config.py # Video directories config
ββ run.py # Local run entrypoint
python3 -m venv .venv
source .venv/bin/activatepip install fastapi uvicorn sqlalchemy jinja2 python-multipartffmpeg and ffprobe improve thumbnail generation and duration detection.
Ubuntu/Debian:
sudo apt update
sudo apt install -y ffmpegSet VIDEO_DIR in config.py. It can be either a string or a list of directories.
VIDEO_DIR = [
"/home/your-user/Videos",
"/home/your-user/Temporary"
]Notes:
- Non-existing directories are skipped.
- Only files under configured roots with supported extensions are indexed.
python run.pyThe server runs on port 8000 and binds to your detected local/LAN IP.
Open in browser:
http://127.0.0.1:8000(same machine)http://<your-local-ip>:8000(same network)
GET /- Home page (video listing)GET /watch?id=<video_id>or/watch?v=<relative_name>- Watch pageGET /thumb/{video_id}- Thumbnail imageGET /stream/{video_id}- Streaming endpointGET /download/{video_id}- Download endpointGET /settings- Settings pageGET /help- Help page
GET /api/list?q=- List videosGET /api/meta?id=<id>- Video metadata and commentsPOST /api/view?id=<id>- Increment view countPOST /api/like?id=<id>- Toggle video like (X-Actor-Idoptional)POST /api/comment?id=<id>- Add comment/reply (Form: author, text, parent_id)POST /api/comment-like?comment_id=<id>- Toggle comment like (X-Actor-Idoptional)
data/video_meta.json- Path-to-ID mapping
- Cached metadata and counters
- Schema-aware migration in route logic
data/dtube.db- Relational storage for videos, comments, and likes
- Automatic table creation and lightweight schema migration at startup
- Quality switching is currently present as an interface parameter, but streaming is currently served from the original source file.
- Initial scanning can take time for very large media folders.
- The app is optimized for local/home-network usage; do not expose publicly without adding authentication and hardening.
- No videos shown: verify
VIDEO_DIRpaths inconfig.py. - Thumbnail missing: ensure
ffmpegis installed and available in PATH. - Duration is
0: ensureffprobeis installed. - Port conflict: change the port in
run.py. - Permission errors: verify read permissions for configured video directories.
- Authentication and user profiles
- Playlists and watch history
- Real transcoding queue + adaptive quality
- Better indexing/caching strategy for very large libraries
- Admin dashboard for media management