Stream Video File
Streaming
Stream Video File
Stream downloaded video files with HTTP range request support for efficient video playback
GET
Stream Video File
Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mario1027/offlinetube/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This endpoint provides video streaming functionality with full HTTP range request support, enabling efficient video playback with seek capabilities. The server implements partial content delivery (HTTP 206 responses) when clients request specific byte ranges.How HTTP Range Streaming Works
The streaming endpoint supports the HTTPRange header, which allows clients to request specific portions of a file. This is essential for:
- Video player seeking: Jump to any point in the video without downloading the entire file
- Bandwidth optimization: Download only the portions of the video being watched
- Resume interrupted downloads: Continue from where playback stopped
- Mobile-friendly playback: Efficient streaming on limited bandwidth connections
Range Request Flow
- Client sends a request with
Range: bytes=start-endheader - Server parses the range and validates bounds
- Server reads the requested chunk from disk (default 64KB blocks)
- Server responds with HTTP 206 (Partial Content) and appropriate headers
- Client receives only the requested portion of the file
Endpoint
The name of the downloaded video file. This should match the filename returned from a completed download task (format:
title__task-id.ext).Request Headers
Optional HTTP range header to request a specific byte range of the file.Format:
bytes=start-endstart: Zero-based byte offset (required)end: Last byte to include (optional, defaults to end of file)
bytes=0-1023- First 1024 bytesbytes=1024-- From byte 1024 to end of filebytes=1000-2000- Bytes 1000 through 2000 inclusive
Response
Without Range Header
Returns the complete file with HTTP 200.video/mp4Total file size in bytes
With Range Header
Returns partial content with HTTP 206.Indicates which bytes are being returned and the total file size.Format:
bytes start-end/totalExample: bytes 0-1023/5242880 (first 1024 bytes of a ~5MB file)Always returns
bytes to indicate the server supports range requestsSize of the returned chunk in bytes (end - start + 1)
video/mp4Implementation Details
Range Parsing
The server parses the Range header using a regex pattern:bytes=(\d+)-(\d*)
- If end byte is not specified, it defaults to the last byte of the file
- The end byte is clamped to
file_size - 1to prevent out-of-bounds reads - Invalid range formats fall back to returning the complete file
Chunk Streaming
The server streams the requested range in 64KB (65536 bytes) blocks:- Memory efficiency: Only 64KB in memory at a time
- Responsive streaming: Data begins flowing immediately
- Proper cleanup: File handle is closed after streaming completes
Examples
Basic Playback (Full File)
Range Request (First 1MB)
Range Request (Resume from 10MB)
Seeking to Middle of Video
Using with HTML5 Video Player
Error Responses
File not foundThe specified filename does not exist in the downloads directory.
Video Player Integration
Most modern video players automatically use range requests:- HTML5
<video>tag: Sends range requests when seeking - Video.js: Full range request support
- Plyr: Automatic range handling
- Mobile browsers: Optimize with range requests on cellular
Performance Considerations
- Chunk size: 64KB blocks balance memory usage and streaming performance
- Disk I/O: Sequential reads are optimized by the OS filesystem cache
- Concurrent streams: Each request opens a separate file handle
- No buffering: Streaming begins immediately, no file pre-loading required
Related Endpoints
- GET /api/download//file - Download complete file (not streaming)
- GET /api/downloads - List all downloads to get filenames