Star Wars: Battlefront, the 2004 game, plays movies behind its menus and flyovers of its maps. They are Bink files, and the game keeps its menu movies back to back inside one archive in the game folder.
Battlefront Eternal is a fan-made engine for that game, written in Rust and published by my company, Centreville Tech. You bring your own copy of the game and it plays from your files. Early previews handled the movies by converting every one of them to WebM while the game was being prepared, which meant a conversion step and a second copy of each movie on disk.
I wanted the engine to open the game folder and play what was already there. So I ported FFmpeg’s Bink demuxer and its Bink video and audio decoders to Rust, and released the port by itself as bink-decoder.
What it is
Bink is a proprietary video format for games. Its owner is Epic Games Tools, formerly RAD Game Tools. bink-decoder is an independent project, not affiliated with or endorsed by them or by the FFmpeg project. It is a port of the decoders in FFmpeg 7.1, and every ported file keeps FFmpeg’s copyright notice.
The crate is safe Rust, with unsafe forbidden for the whole crate, and it depends on nothing outside the standard library. You hand it anything that can read and seek, and it gives back one frame at a time:
let f = File::open("movie.bik")?;
let f = BufReader::new(f);
let mut bik = Decoder::new(f)?;
while let Some(frame) =
bik.next_frame()?
{
// frame.picture
// frame.audio
// frame.time
}
Pictures come out as planar YUV 4:2:0 and sound as 32-bit float samples. The decoder never loads the whole file. If the movie sits in the middle of a bigger file, you seek to its first byte before you make the decoder, and that is how Battlefront Eternal plays a movie out of the game’s archive without copying it anywhere.
How a frame gets decoded

A Bink 1 file starts with a fixed header, a table of audio tracks and an index with one entry for each frame. Here is the start of one, a small test file from the repository that the tests write bit by bit.

Most of the work is in the video packet. Each plane of the picture is cut into 8x8 blocks. The packet first carries nine streams of values, each one Huffman coded, and then every block draws itself from those streams according to its type, and there are ten.

What it decodes
- Container. Bink 1 files. Bink 2 files and SMUSH-wrapped files are not supported.
- Video. Bink 1 revisions f, g, h, i and k, with every block type, motion compensation and the alpha plane. The old revision b is not supported.
- Audio. The DCT variant of Bink audio, mono or stereo. The RDFT variant is not supported.
Only revision i video and stereo 48 kHz audio have been checked against real files. The code for the other revisions is ported as FFmpeg has it, and so far it has only run on the synthetic tests and under the fuzzers.
How I checked it
I checked it against FFmpeg. On a set of 56 revision i movies, every video frame from bink-decoder was equal to FFmpeg’s output byte for byte. Twenty-three of those files had sound, and the largest difference in any sample was 0.000006. The audio isn’t bit for bit because FFmpeg does that transform in single precision and this decoder does it in double.
Those are real movies, so they are not in the repository, and that comparison runs locally instead of in CI. Nothing in the repository comes from a commercial product. The tests that run on every push build their own tiny Bink files a bit at a time.

A movie file can be damaged or hostile, so I also ran the decoder under five fuzzers: one for the whole decoder, one each for the video decoder, the audio decoder and the container reader, and one for the bit-level readers. They found three things. A header that declared a huge frame made the reader allocate that much memory before reading anything. The video decoder accepted a picture size of zero, or one far too large. And a decoder that was reset, or rewound after a damaged first frame, could show pixels left over from before. All three are fixed and each has a test.
After the last fix, each target ran for 30 minutes and then 20 more on the current code without finding anything else. A shorter run happens on every push.

How fast it is

A movie at 30 frames a second needs a new frame every 33 milliseconds. On one thread, a low-end laptop from 2014 decodes an 800x600 frame in about 2.4 milliseconds, and the slowest frame took 8. Old menu movies are not a hard workload, but the engine has a game to run in the other 31.
Where to get it
The code is on GitHub at version 0.1.0. There is no tagged release yet and it is not on crates.io, so you add it to a project as a git dependency. It needs Rust 1.75 or later.
The license is GPL 3.0 only. FFmpeg’s decoders are under the LGPL 2.1 or later, and that license lets a derived work be placed under the GPL, which is what this port does.
It is one of two Rust libraries that came out of Battlefront Eternal. The other is rar-reader, which reads RAR archives for the mod manager. Most of the other open source on this site is for phones and radios: Ti.Socketline and Ti.Paysheet for Titanium apps, and a SIM card generator for private LTE and 5G networks.
Do you have files in an old format and software that can no longer open them? That is custom software I take on. Send me an email and tell me what the files are.
