PixiJS was killing my video exports. So I rewrote the pipeline in Rust
a day ago
- #Video Export Optimization
- #PixiJS
- #Rust
- PixiJS's main thread bottleneck in a screen recorder editor caused slow video exports and UI freezes, prompting a rewrite of the export pipeline in Rust.
- The Rust solution uses a separate binary with ffmpeg for decoding, Metal compositor for GPU-based compositing, and hardware encoding via VideoToolbox, eliminating per-frame data copies and improving performance.
- Export times dropped from 15 minutes to 1 minute for a 5-minute 720p clip on an M-series Mac, with the added benefit of a responsive UI as the process runs separately.
- Rust was chosen for its build simplicity, cross-platform potential, and crate ecosystem, despite alternatives like C++ or Swift being viable.
- Key lessons include prioritizing architectural changes over micro-optimizations, moving long tasks off the main thread for better UX, and considering fallback options like the existing JS pipeline for web compatibility.