Video Subgraph โ Integration Guide
Overview
The video subgraph handles extremely CPU-intensive FFmpeg transcoding. Like the imaging service, it operates completely out-of-band to prevent gateway latency spikes when users upload massive MP4 arrays.
Architecture at a Glance
| Component | Technology | Port | Access |
|---|---|---|---|
| Framework | NestJS (TCP Microservice) | 30021 | Read/Write DB |
| Engine | FFmpeg (Alpine) + fluent-ffmpeg |
โ | Internal Network |
Processing Pipeline
For an architectural breakdown of how video intersects with Hash deduplication, see the Media Intelligence architecture guide.
1. HTTP Live Streaming (HLS)
The standard output is not an .mp4 file, but an .m3u8 adaptive bitrate VOD playlist bundled with 6-second .ts segments, encrypted with AES-128 via Cloudflare.
2. Auto-Poster Generation
As part of the same FFmpeg pipe, a high-quality .jpg poster frame is captured at the 1-second mark, providing instant cover images without additional overhead.
3. Infrastructure Considerations
- Relies on native binary compilation on the host machine. (The
alpine apk add ffmpegapproach replaces the deprecated@ffmpeg-installer). - Reads directly off configured S3/R2 storage, transcodes in temporary directory
/tmp, and streams back up, bypassing application memory load to avoid OOM crashes.
Future Trajectory: Rust Rewrite
Because this service is cleanly decoupled by a simple TCP contract (transcode_video_hls), the planned trajectory is to rewrite apps/video entirely in Rust using ffmpeg-sys + tokio. This transition is slated to decrease memory overhead by an estimated 95% making container density substantially higher for the video pipeline.