1个不稳定版本
0.1.0 | 2022年9月22日 |
---|
#383 在 多媒体
30KB
481 行
roq-dec
一个用于在Rust中解码ROQ视频流的轻量级crate
用法
将以下行添加到您的Cargo.toml依赖项
roq-dec = "0.1.0"
从文件创建一个ROQ解码器
let roqfile = File::open("path/to/video.roq").expect("Failed to open file");
let mut roqdec: RoqDecoder<File,u32,ColorspaceRgba8888> = RoqDecoder::new(roqfile).expect("Failed to initialize ROQ decoder");
从ROQ解码器读取数据
match roqdec.read_next()? {
RoqEvent::InitVideo => {
println!("Video dimensions: ({}, {}), Framerate: {}", roqdec.width, roqdec.height, roqdec.framerate);
},
RoqEvent::Video(framedata) => {
// framedata is an array of width*height of pixel color type (using ColorspaceRgba8888, this will be &[u32])
},
RoqEvent::Audio(channels, samples) => {
// channels will be either 1 or 2, samples is &[u16]
},
RoqEvent::Custom(chunk_id, chunk_arg, chunk_data) => {
// handle custom chunk types here
// chunk_data is Vec<u8> of chunk data
},
RoqEvent::EndOfFile => {
// reached end of file
}
};
依赖项
~125KB