Skip to content

A FLV format parsing library written in Rust with nom.

License

Notifications You must be signed in to change notification settings

koushiro/flvparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flvparse

A toy FLV format parsing library written in Rust with nom, mainly for learning nom (not production-ready).

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
┌─────────────────────────────┐
│ Field             Value     │
╞═════════════════════════════╡
│ Signature (3B)    46 4c 56  │
│ Version (1B)      1         │
│ Flags (1B)        0000 0101 │
│ DataOffset (4B)   9         │
└─────────────────────────────┘
Tag Summary
┌────────────────────────────────────────────────────────────────────────────┐
│ 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
┌─────────────────────────────┐
│ Field             Value     │
╞═════════════════════════════╡
│ 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             │
│ 5       Video          104             41               0             │
| ...                                                                   |
│ 13038   Audio          15              194471           0             │
│ 13039   Audio          15              194494           0             │
│ 13040   Audio          15              194517           0             │
│ 13041   Video          5               194375           0             │
└───────────────────────────────────────────────────────────────────────┘
Tag Summary
┌────────────────────────────────────────────────────────────────────────────┐
│ 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

This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.

About

A FLV format parsing library written in Rust with nom.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •