Backend Development
Open Source

Smart TV Local Media Server: Rust & Axum Backend

RustAxumTokioTowerFFmpegTracingSerde

A high-performance, asynchronous media streaming and indexing server built in Rust. It dynamically generates video thumbnails and temporal scrubbing previews via FFmpeg subprocesses while efficiently serving raw media files over HTTP.

Tech Stack

RustAxumTokioTowerFFmpegTracingSerde

System Metrics

Zero-overhead asynchronous I/O prevents thread starvation during simultaneous media streaming and FFmpeg execution
Headless, resource-minimal memory footprint compared to JVM or Node.js based media servers
Efficient localized frame extraction minimizes CPU thrashing by generating only surrounding frames during video scrubbing

Why Did I Build This?

"Streaming massive local media files to a Smart TV requires a low-latency, zero-overhead backend. Off-the-shelf media servers like Plex or Jellyfin are inherently bloated and resource-intensive. I engineered this lightweight Rust backend to interface directly with a custom Flutter Smart TV client. It handles on-the-fly FFmpeg frame extraction for seek-bar scrubbing and provides static file serving without the massive CPU and RAM footprint of traditional media servers."

Architecture & Decisions

The architecture is built on the Tokio asynchronous runtime and the Axum web framework. It utilizes `tower-http` for highly optimized, zero-copy static file serving. Media directory traversal and FFmpeg frame extraction (`tokio::process::Command`) are executed asynchronously, preventing I/O thread blocking during heavy loads. The server features a recursive boot-time preloader to cache standard thumbnails and an on-demand generator for temporal seek-bar scrubbing (extracting localized frame sequences for preview). Logging is strictly handled via the non-blocking `tracing_appender` to ensure zero I/O latency bottlenecks.

Key Features

  • 01.Asynchronous media indexing and recursive directory traversal
  • 02.On-the-fly FFmpeg subprocess orchestration for temporal scrub thumbnail generation
  • 03.Zero-copy static media serving via the `tower-http` layer
  • 04.Recursive boot-time thumbnail preloader ensuring immediate cache readiness
  • 05.Non-blocking, daily rolling logs via the `tracing` ecosystem
This backend demonstrates aggressive optimization in local media serving. By delegating static file delivery to the highly optimized `tower-http` layer and handling expensive `ffmpeg` extraction strictly via non-blocking Tokio tasks, the server maintains absolute memory safety and runs flawlessly on low-power NAS hardware or single-board computers, directly feeding the Flutter frontend.