How the Local Audio Cache System works
mainBeatra uses a local caching system to prevent playback interruptions like buffering, stuttering, or voice crackling. Instead of streaming directly from external URLs (YouTube, Spotify, SoundCloud), the bot pre-downloads tracks to a local directory before playback.
Workflow:
- Queue Detection: Triggered by
/playor autoplay. - Background Download: Tracks are downloaded silently while the current song plays.
- Smart Preloading: The entire queue is preloaded in parallel for instant transitions.
- Local Streaming: FFmpeg streams the cached
.opusfile to Discord. - Automatic Cleanup: Files are deleted after playback to save space.
Technical Specifications:
- Cache Directory:
audio_cache/(automatically created). - Format: Opus audio (
.opus) for optimal Discord quality. - Naming Convention:
track_[MD5 hash].opus. - Disk Space Requirements: While usage is minimal (~30-80 MB for a 10-track queue), it is recommended to have at least 500 MB free space on VPS deployments to handle large queues comfortably.