Skip to content

About

Incremental migration of FFmpeg's libraries to safe Rust, produced by Crustify

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ffmpeg-crustify

An incremental, bottom-up migration of FFmpeg's libraries from C to Rust.

So far, 42.8% of FFmpeg's public C API is available as safe Rust bindings, and 71.3% of libavutil's, the first library wrapped: a safe, idiomatic Rust interface, implemented for now by FFmpeg's C through unsafe Rust, with the raw bindings in one <lib>-sys crate per library.

Roadmap

  1. Bind (in progress): put a safe Rust API in front of all of FFmpeg's public C API.
  2. Migrate: module by module, from the bottom of the dependency order up, port the C behind the bindings to safe Rust and swap it in for the unsafe implementation, without breaking the API's consumers.
  3. Ship hybrids: every step ships as an interoperable build that mixes C and Rust, the modules migrated so far in Rust and the rest still in C.

How it was made

The bindings were generated by Crustify, a specification-driven AI co-translator developed at UC Berkeley, and reviewed by its own independent, adversarial agents; the paper details the campaign.

  • Models: mainly Claude Opus 5.5. GPT-6.1 Sol wrapped the crypto module and GPT-6 Astra reviewed one batch; Claude Fable 5.1 ran the early reviews.
  • wavefront: CodeQL-based analysis of the C that plans the work in dependency order.
  • ffibox: ownership and borrowed-handle types the bindings hold C memory through.
  • ffimap: maps the unsafe code and raw pointers left on the public API.
  • bindgen for the raw bindings; ASan/UBSan, TSan, Miri and BorrowSanitizer to check for undefined behavior.
  • glibc-bindings for the libc types FFmpeg's API uses (struct tm).

Results

Public API wrapped 573 of 1,338 items (42.8%) over all 7 libraries: 57 of 210 types, 516 of 1,128 symbols; 573 of 804 (71.3%) in libavutil
Tests 2,694: 968 unit, 723 equivalence with the C, 821 UB on the safe API, 182 UB on the unsafe API
Line coverage 99.1% of the Rust, 67.2% of libavutil's C
unsafe public functions 11 of 2,637 (0.4%) on the consumer-facing interface; 63 (2.4%) with ffibox's trait methods and raw constructors
Raw pointers in 16 consumer-facing public functions' signatures (0.6%); none in public fields
UB defects the reviewers fixed 13
Rust 18,681 lines of code
Wall-clock time, cost 58.9 hours, $2,120 for every agent

The campaign's plan, review reports and dashboard are under crustify/.

License

LGPL-2.1-or-later, as FFmpeg.

About

Incremental migration of FFmpeg's libraries to safe Rust, produced by Crustify

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages