Crates.io | flvparse |
lib.rs | flvparse |
version | 0.1.0 |
source | src |
created_at | 2021-02-15 10:28:56.267034 |
updated_at | 2021-02-15 10:28:56.267034 |
description | A FLV format parsing library written in Rust |
homepage | |
repository | https://github.com/koushiro/flvparse |
max_upload_size | |
id | 355428 |
size | 45,229 |
A FLV format parsing library written in Rust with nom.
[dependencies]
flvparse = "0.1"
fn main() {
let bytes = include_bytes!("assets/test.flv");
let flv = flvparse::FlvFile::parse(bytes).unwrap();
// ...
}
See example for details.
cd cmd
cargo run -- --input ../assets/test.flv
+-----------------+-----------+
| FLV File Header | |
+-----------------+-----------+
| Signature (3B) | 46 4c 56 |
| Version (1B) | 1 |
| Flags (1B) | 0000 0101 |
| DataOffset (4B) | 9 |
+-----------------+-----------+
+------------------+-------------------+------------------+------------------+
| Total tag number | Script tag number | Video tag number | Audio tag number |
+------------------+-------------------+------------------+------------------+
| 13041 | 1 | 4668 | 8372 |
+------------------+-------------------+------------------+------------------+
cd cmd
cargo run -- --input ../assets/test.flv -p
+-----------------+-----------+
| FLV File Header | |
+-----------------+-----------+
| Signature (3B) | 46 4c 56 |
| Version (1B) | 1 |
| Flags (1B) | 0000 0101 |
| DataOffset (4B) | 9 |
+-----------------+-----------+
+---------------+--------------+---------------+----------------+---------------+
| FLV File Body | | | | |
+---------------+--------------+---------------+----------------+---------------+
| Index | TagType (1B) | DataSize (3B) | Timestamp (4B) | StreamID (3B) |
| 1 | Script | 1030 | 0 | 0 |
| 2 | Video | 48 | 0 | 0 |
| 3 | Audio | 7 | 0 | 0 |
| 4 | Video | 2831 | 0 | 0 |
| ... |
| 13039 | Audio | 15 | 194494 | 0 |
| 13040 | Audio | 15 | 194517 | 0 |
| 13041 | Video | 5 | 194375 | 0 |
+---------------+--------------+---------------+----------------+---------------+
+------------------+-------------------+------------------+------------------+
| Total tag number | Script tag number | Video tag number | Audio tag number |
+------------------+-------------------+------------------+------------------+
| 13041 | 1 | 4668 | 8372 |
+------------------+-------------------+------------------+------------------+
FlvFile
├──FlvFileHeader
└──FlvFileBody
├──u32 -- first previous tag size
└──Vec<(FlvTag, u32)>
FlvTag
├──FlvTagHeader
└──FlvTagData
FlvTagData
└──ScriptTag/VideoTag/AudioTag
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.