Streaming Overview
Plank uses a smart streaming system that combines torrent downloading with HTTP range requests to provide smooth playback:Instant Playback
Start watching as soon as ~5% of the file has downloaded. The player buffers ahead while you watch.
Format Transcoding
Automatic real-time transcoding for MKV and AVI files to browser-compatible MP4 using FFmpeg.
Range Requests
HTTP range request support allows seeking anywhere in the video, even if that part hasn’t downloaded yet.
Adaptive Buffering
Smart buffering prioritizes the parts you’re watching while continuing to download the full file.
How Streaming Works
When you click play on media:- Torrent Initialization: Plank starts the torrent download if not already active
- Video Detection: Identifies the primary video file in the torrent
- Buffering: Downloads the first ~5% of the file for initial playback
- Stream Start: Video player begins playback
- Progressive Download: Continues downloading while you watch
For Movies
Movie streaming is straightforward:- Single video file per torrent
- Automatic quality detection
- Full range-seeking support
- Progress saved across sessions
For TV Episodes
TV episodes require additional logic:- Torrent may contain multiple episodes
- Files mapped to TMDB episode metadata
- Per-episode progress tracking
- File index selection for multi-file torrents
Video Player Features
Built on Vidstack
Plank uses Vidstack, a modern video player framework with:- Responsive Controls: Touch-friendly playback controls
- Keyboard Shortcuts: Space to play/pause, arrow keys to seek, F for fullscreen
- Gesture Support: Tap to show/hide controls, swipe gestures
- Picture-in-Picture: Watch in a floating window
- Fullscreen: Native fullscreen support on all devices
Playback Controls
- Play/Pause: Click video or use spacebar
- Seek: Drag the progress bar or use arrow keys (±10 seconds)
- Volume: Adjust volume and mute controls
- Playback Speed: Change speed from 0.25x to 2x
- Quality: Automatic quality based on source file
- Subtitles: Select from available subtitle tracks
Progress Tracking
Your playback position is automatically saved:- Auto-save: Position saved every 5 seconds
- Resume on Return: Automatically resume from last position
- Completion Detection: Marks as complete when you watch to the end
- Cross-Session: Progress persists even if you close the browser
- Beacon Fallback: Uses sendBeacon API to save position on page unload
File Format Support
Native Formats
These formats play directly in the browser without transcoding:- MP4 (H.264/H.265 video, AAC audio)
- WebM (VP8/VP9 video, Vorbis/Opus audio)
Transcoded Formats
These formats are automatically transcoded to MP4 in real-time:- MKV (Matroska)
- AVI (Audio Video Interleave)
- MOV (QuickTime)
- Use FFmpeg for real-time conversion
- Slightly higher CPU usage on the server
- No seeking support during transcoding
- Cached to library as MP4 when complete
MIME Type Detection
Plank automatically detects video formats and sets proper MIME types:Streaming States
The video player shows different states during streaming:Initializing
Shown when the torrent is being added to the download manager:- Animated spinner with pulsing ring
- “Loading…” message
- Background poster image (blurred)
Buffering
Displayed when waiting for enough data to start playback:- Download speed indicator
- Peer count
- Progress percentage
- Visual progress bar
Playing
Normal playback with full controls:- Vidstack player controls
- Subtitle selection
- Quality display
- Playback speed control
Error States
If streaming fails, you’ll see:- Error message (e.g., “No seeders available”)
- Retry option
- Go back button
Download Stats During Playback
Toggle stats overlay from the player menu to see:- Download Speed: Current download speed in MB/s or KB/s
- Peer Count: Number of connected peers
- Progress Bar: Visual download progress
- Torrent Status: Real-time status updates
- Whether the buffer is staying ahead of playback
- If you’re connected to enough peers
- Estimated time until full download
Advanced: Range Requests
Plank’s streaming engine supports HTTP range requests, which enable:Seeking While Downloading
When you seek to a new position:- Player requests specific byte range
- Torrent client prioritizes downloading that range
- Playback resumes once enough data is available
- Background download continues for the full file
Library Files
Completed files in your library use standard range requests:- Instant seeking to any position
- Lower server resource usage
- Cached with
max-age=3600headers - No transcoding overhead
Downloading Files
Files still downloading use torrent-based range requests:- Dynamic range generation
- Prioritized piece downloading
Cache-Control: no-cacheheaders- May require buffering for seeks
Performance Optimization
Server-Side
- Stream Reuse: Streams are created on-demand and destroyed when done
- Error Handling: Graceful handling of client disconnects
- Backpressure: Proper Node.js stream backpressure handling
- Memory Management: Streams destroyed on abort to prevent leaks
Client-Side
- Adaptive Buffering: Player automatically adjusts buffer size
- Prefetching: Vidstack prefetches upcoming segments
- Lazy Loading: Video player only loads when media is ready
- Resource Cleanup: Proper cleanup on page navigation
Troubleshooting Streaming Issues
Video Won’t Start
- Check peers: Make sure torrent has seeders (check stats)
- Wait for buffer: Give it 30-60 seconds to buffer
- Check format: Some exotic codecs may not be supported
- Retry download: Use retry button on media page
Buffering/Stuttering
- Slow download: Check download speed in stats overlay
- Low peers: Torrent may have few seeders
- Server load: High CPU usage from transcoding (MKV/AVI)
- Seek less: Let buffer build up before seeking
Seeking Not Working
- Transcoded files: MKV/AVI don’t support seeking during transcode
- Still downloading: May need to wait for target range to download
- Wait for completion: Seeking works perfectly on completed files
Next Steps
Subtitles
Learn how to add and manage subtitles for your videos
Media Library
Organize and manage your streaming collection