ass-renderer
⚠️ WORK IN PROGRESS - This renderer is currently under active development. While the software backend is functional, some features may be incomplete and the API is subject to change.
High-performance ASS (Advanced SubStation Alpha) subtitle renderer with modular backend support.
Features
-
Rendering Backends
- Software (CPU) rendering with tiny-skia (RECOMMENDED - fully implemented)
- GPU hybrid compositor via
wgpu(uploads the software backend's coverage/RGBA tiles and composites them on the GPU; one path covers Vulkan/Metal/DX12/GL natively) - Automatic backend selection (defaults to Software)
-
Complete ASS/SSA Support
- All ASS v4+ tags and formatting
- Style inheritance and resolution
- Complex positioning (pos, move, org)
- Animation support (\t tags)
- Karaoke effects
- Drawing commands (\p)
- Clipping (\clip, \iclip)
-
Advanced Features
- Collision detection and resolution
- Incremental rendering for performance
- Plugin system for custom effects
- Comprehensive caching system
- Zero-copy design where possible
Usage
use ;
use Script;
// Parse ASS script
let script = parse?;
// Create rendering context
let context = new;
// Create renderer with automatic backend selection
let mut renderer = with_auto_backend?;
// Render frame at specific time (in centiseconds)
let frame = renderer.render_frame?;
// Access pixel data
let pixels = frame.data; // RGBA8 format
Backends
Software Backend (RECOMMENDED)
Pure CPU rendering using tiny-skia. Fully implemented and production-ready. Works everywhere, no GPU dependencies.
use ;
// Recommended: Use Software backend explicitly
let mut renderer = new?;
GPU Backend (gpu feature)
A wgpu-based hybrid compositor. It does not re-rasterize glyphs/shapes on the
GPU; instead it reuses the software backend's cached coverage/RGBA tiles, uploads them
as textures, and composites them with a textured-quad shader — so it inherits the
software backend's parity. A single wgpu path covers Vulkan/Metal/DX12/GL natively.
use ;
// Requires building with --features gpu
let mut renderer = new?;
Note: for this lightweight compositing workload the GPU path pays an upload + readback cost and is currently slower than the already-fast CPU backend; its value is GPU offload and a future browser (WebGPU) target. For production we recommend the Software backend.
Collision Detection
Automatic collision detection prevents subtitle overlap:
use ;
let mut resolver = new;
// Add fixed event
resolver.add_fixed;
// Find non-colliding position for new event
let new_position = resolver.find_position;
Animation System
Support for ASS animation tags (\t):
use ;
let mut controller = new;
// Add animation track
let timing = new;
let track = new;
controller.add_track;
// Evaluate at specific time
let state = controller.evaluate;
Performance
Optimized for high performance:
- Target: <5ms per 4K frame
- SIMD acceleration (when enabled)
- Incremental rendering support
- Extensive caching
- Parallel processing with rayon
Feature Flags
default: Enables software backend and analysis integrationsoftware-backend: CPU rendering supportgpu: wgpu hybrid GPU compositor (native; requiressoftware-backend)simd: SIMD accelerationarena: Arena allocator for reduced allocationsanalysis-integration: Integration with ass-core analysisbackend-metrics: Performance metrics collectionserde: Serialization supportnostd: No-std support (limited backends)
Benchmarks
Run benchmarks with:
Performance targets (vs libass):
- Simple subtitles: 2-3x faster
- Complex effects: 1.5-2x faster
- 4K rendering: <5ms per frame
- Memory usage: ~1.1x input size
Testing
License
MIT OR Apache-2.0