#audio-video #file-format #chunks #io #reading #wave #write

riff

此软件包提供了读取和写入 RIFF 格式文件的实用工具

5 个版本 (3 个稳定)

2.0.0 2023 年 6 月 15 日
1.0.1 2020 年 7 月 29 日
1.0.0 2020 年 4 月 26 日
0.1.1 2018 年 7 月 3 日
0.1.0 2018 年 7 月 3 日

#12多媒体

Download history 11787/week @ 2024-04-23 14896/week @ 2024-04-30 14000/week @ 2024-05-07 25317/week @ 2024-05-14 30642/week @ 2024-05-21 44456/week @ 2024-05-28 45251/week @ 2024-06-04 35993/week @ 2024-06-11 27637/week @ 2024-06-18 34115/week @ 2024-06-25 22943/week @ 2024-07-02 38050/week @ 2024-07-09 53485/week @ 2024-07-16 35633/week @ 2024-07-23 57604/week @ 2024-07-30 38487/week @ 2024-08-06

190,314 每月下载量
用于 51 个软件包 (5 个直接)

MIT 许可证

12KB
217

riff

用于在 RIFF 格式文件上进行 IO 的软件包

此软件包提供了读取和写入 Microsoft Wave、Audio Video Interleave 或 Downloadable Sounds 等格式的实用方法。

示例

读取块

let mut file = File::open("somefile.wav")?;
let chunk = riff::Chunk::read(&mut file, 0)?;

for child in chunk.iter(&mut file) {
  println!(child.id());
}

写入块

// Some ids to use while creating chunks
let smpl_id: ChunkId = ChunkId { value: [0x73, 0x6D, 0x70, 0x6C] };
let test_id: ChunkId = ChunkId { value: [0x74, 0x65, 0x73, 0x74] };
let tst1_id: ChunkId = ChunkId { value: [0x74, 0x73, 0x74, 0x31] };
let tst2_id: ChunkId = ChunkId { value: [0x74, 0x73, 0x74, 0x32] };

let str1 = "hey this is a test".as_bytes().to_vec();
let str2 = "hey this is another test".as_bytes().to_vec();
let str3 = "final test".as_bytes().to_vec();

let contents = ChunkContents::Children(
  riff::RIFF_ID,
  smpl_id,
  vec![
    ChunkContents::Children(
      riff::LIST_ID,
      tst1_id,
      vec![
        ChunkContents::Data(test_id, str1),
        ChunkContents::Data(test_id, str2)
      ]),
    ChunkContents::Children(
      riff::LIST_ID,
      tst2_id,
      vec![
        ChunkContents::Data(test_id, str3)
      ]
    )
  ]);

let mut file = File::create("somefile.riff")?;
contents.write(&mut file)?;

无运行时依赖