mp4

A pure-Rust library to read and write ISO-MP4 (ISOBMFF) files, parsing boxes, tracks, and metadata.

Library
Cargo
v0.14.0
353stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
45/100Fair
Development Activity0
Maintenance32
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture80
Code Quality78
Innovation72
Learning Curve76

mp4 is a Rust library for reading and writing ISO-MP4 files based on the ISO Base Media File Format (ISOBMFF). It implements the relevant MPEG-4 specification parts, letting you parse the box structure of a QuickTime or MP4 container, inspect the ftyp and moov boxes, and enumerate tracks with their type, language, and timing.

Beyond reading, it also supports writing MP4 output, making it usable for muxing and container manipulation. The library is dependency-light pure Rust and compiles to WebAssembly, so the same parsing logic powers browser-based inspectors as well as native tools.

What You Get

  • An Mp4Reader that reads the MP4/ISOBMFF box header from a buffered reader
  • Typed access to ftyp, moov/mvhd, tracks, timescale, duration, and compatible brands
  • Track inspection: track_id, language, track_type, and box_type per track
  • Writer support for muxing and producing ISO-MP4 output
  • WebAssembly compatibility for running the parser in the browser

Common Use Cases

  • Extracting metadata (duration, tracks, brands) from an MP4 file
  • Inspecting the box structure of a QuickTime or MP4 container
  • Muxing or rewriting MP4 containers from Rust
  • Building a browser-based MP4 inspector via WebAssembly

Under The Hood

Architecture - The library models the MP4/ISOBMFF format as a tree of typed boxes. Mp4Reader::read_header walks the container from a Read + Seek source, decoding the top-level ftyp and moov boxes and nested structures (mvhd, trak, mdia, etc.) into Rust structs. Track objects wrap the underlying boxes and expose accessors (track_id, language, track_type, box_type) computed from the parsed data, while writer types serialize boxes back out for muxing.

Tech Stack - 100% Rust with a small dependency footprint, distributed as the mp4 Cargo crate and documented on docs.rs. It uses byteorder-style binary reading, criterion for benchmarks, and integrates cleanly with WebAssembly toolchains (used by the companion mp4-inspector project).

Code Quality - The project ships a test suite (cargo test with sample .mp4 fixtures), benchmark tests via criterion, and CI enforcing rustfmt and clippy with warnings denied. It has 24 releases and 24 contributors, though development has been largely inactive since mid-2024.

API Design - The public API is approachable: open a file, call Mp4Reader::read_header(reader, size), then read fields and iterate mp4.tracks(). Method names map directly to MP4 concepts (duration, timescale, compatible_brands), and the README plus examples/ directory (mp4info, mp4dump) give clear starting points, keeping boilerplate minimal.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search