flvparse

Crates.ioflvparse
lib.rsflvparse
version0.1.0
sourcesrc
created_at2021-02-15 10:28:56.267034
updated_at2021-02-15 10:28:56.267034
descriptionA FLV format parsing library written in Rust
homepage
repositoryhttps://github.com/koushiro/flvparse
max_upload_size
id355428
size45,229
Qinxuan Chen (koushiro)

documentation

https://docs.rs/flvparse

README

flvparse

ga-svg crates-svg docs-svg codecov-svg deps-svg

A FLV format parsing library written in Rust with nom.

Usage

Quick start

[dependencies]
flvparse = "0.1"
fn main() {
    let bytes = include_bytes!("assets/test.flv");
    let flv = flvparse::FlvFile::parse(bytes).unwrap();
    // ...
}

Example

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             |
+------------------+-------------------+------------------+------------------+

Related structure

FlvFile
├──FlvFileHeader
└──FlvFileBody
   ├──u32 -- first previous tag size
   └──Vec<(FlvTag, u32)>
    
FlvTag
├──FlvTagHeader
└──FlvTagData

FlvTagData
└──ScriptTag/VideoTag/AudioTag

License

Licensed under either of

at your option.

Contribution

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.

Commit count: 33

cargo fmt