#crypto

mp4decrypt

Decrypt and split mp4 streams using Bento4

4 releases

Uses new Rust 2021

0.2.1+1.6.0-639 Sep 18, 2022
0.2.0+1.6.0-639 Sep 13, 2022
0.1.1+1.6.0-639 Aug 31, 2022
0.1.0+1.6.0-639 Aug 31, 2022

#638 in Cryptography

Download history 37/week @ 2022-08-31 15/week @ 2022-09-07 41/week @ 2022-09-14 4/week @ 2022-09-21

97 downloads per month

MIT/Apache

2MB
33K SLoC

C++ 33K SLoC // 0.3% comments Rust 177 SLoC // 0.1% comments

mp4decrypt

This library provides a safe function to decrypt encrypted mp4 data stream using Bento4. Splitting mp4 streams can also be done.

Getting Started

Add this to your Cargo.toml file.

[dependencies]
mp4decrypt = "0.2.1"

# Or add from github main branch.
mp4decrypt = { git = "https://github.com/clitic/mp4decrypt.git", branch = "main" }

Or add from command line.

$ cargo add mp4decrypt

See docs and examples to know how to use it.

Example

use std::collections::HashMap;
use std::io::Write;

fn main() {
    let mut input = include_bytes!("init.mp4").to_vec();
    input.extend(include_bytes!("segment_0.m4s"));

    let mut keys = HashMap::new();
    keys.insert(
        "eb676abbcb345e96bbcf616630f1a3da".to_owned(),
        "100b6c20940f779a4589152b57d2dacb".to_owned(),
    );

    let decrypted_data = mp4decrypt::mp4decrypt(&input, keys, None).unwrap();

    std::fs::File::create("decrypted.mp4")
        .unwrap()
        .write_all(&decrypted_data)
        .unwrap();
}

License

Dual Licensed

No runtime deps