Overview
The server provides:- HLS Transcoding: Converts video streams to HTTP Live Streaming format
- Torrent Streaming: Streams content directly from torrent/magnet links
- Media Probing: Analyzes video files for metadata and codec information
- Session Management: Handles multiple concurrent streaming sessions
- Chromecast Support: Streaming to Chromecast devices
Prerequisites
- Go 1.25+ (specified in
go.mod) - CGO: Required for SQLite support
- C Compiler:
- Windows: GCC (via MinGW or TDM-GCC)
- macOS: Xcode Command Line Tools
- Linux: GCC (usually pre-installed)
Project Structure
Dependencies
Key dependencies fromgo.mod:
Building Standalone
Basic Build
To build the server binary directly:Optimized Build
For smaller binary size and better performance:-ldflags="-s -w": Strip debug info and symbol table-tags=sqlite_omit_load_extension: Disable SQLite extension loading-o decoder: Output filename
Platform-Specific Builds
The desktop app usesraffi-desktop/build_binary.cjs to compile platform-specific binaries.
Windows Build
decoder-windows-amd64.exe
Requirements:
- GCC compiler (MinGW-w64 or TDM-GCC)
- Static linking for portability
Linux Build
decoder-x86_64-unknown-linux-gnu
Requirements:
- GCC compiler
- Static linking for compatibility across distributions
macOS Build (ARM64)
decoder-aarch64-apple-darwin
Architecture: Apple Silicon (M1/M2/M3)
macOS Build (x64)
decoder-x86_64-apple-darwin
Architecture: Intel-based Macs
Cross-Compilation
To build for different platforms from a single machine:Set target OS and architecture
GOOS=windows GOARCH=amd64GOOS=linux GOARCH=amd64GOOS=darwin GOARCH=amd64GOOS=darwin GOARCH=arm64
Install cross-compilation tools
For cross-compiling with CGO, you need platform-specific C compilers:
Building from Desktop App
The desktop app automatically builds the server binary:Run the server build script
build_binary.cjs which:- Detects your current platform
- Compiles the Go server with appropriate flags
- Outputs to
raffi-desktop/electron/decoder-{platform}
Build Output Locations
When building from the desktop app, binaries are placed in:extraResources during packaging.
Binary Size Optimization
The build process optimizes binary size:| Flag | Purpose | Size Reduction |
|---|---|---|
-ldflags="-s" | Strip debug info | ~30% |
-ldflags="-w" | Strip symbol table | ~10% |
-tags=sqlite_omit_load_extension | Remove SQLite extensions | ~5% |
-extldflags '-static' | Static linking | Varies |
- Windows: ~45 MB
- Linux: ~40 MB
- macOS: ~42 MB
Testing the Server
After building, test the server independently:Environment Variables
The server supports configuration via environment variables:Deployment
Desktop App Bundle
The server binary is automatically bundled with the desktop app and managed by Electron:- Windows:
resources/decoder-windows-amd64.exe - Linux:
resources/decoder-x86_64-unknown-linux-gnu - macOS:
resources/decoder-{arch}-apple-darwin
Standalone Server
For running the server independently (e.g., for mobile clients):Mobile Integration
The mobile app connects to the server for torrent streaming:- Desktop app runs server on local network
- Mobile app connects via
http://{desktop-ip}:8080 - Server handles transcoding and streaming