作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在不使用外部库的情况下制作自己的FLV音频下载器。
我正在关注此文档:
http://osflash.org/flv
在FLV标签类型中,有三个有趣的值:
BodyLength,Timestamp,StreamId是uint24_be
类型。如何阅读它们?
我在这里找到了答案:
Extract Audio from FLV stream in C#
但是我不明白几件事:
如果Timestamp和StreamId都是uint24_be
(又是uint24_be
?),那么为什么
reader.ReadInt32(); //skip timestamps
ReadNext3Bytes(reader); // skip streamID
ReadNext3Bytes
到底做什么?为什么不读取这样的下3个字节:
reader.ReadInt32()+reader.ReadInt32()+reader.ReadInt32();
最佳答案
您不能使用reader.ReadInt32()+reader.ReadInt32()+reader.ReadInt32()
,因为起初它是12个字节而不是3个字节,而第二个字节对这些字节进行汇总还不够简单-您应该设置24位值。这是ReadNext3Bytes
函数的可读性更高的版本:
int ReadNext3Bytes(System.IO.BinaryReader reader) {
try {
byte b0 = reader.ReadByte();
byte b1 = reader.ReadByte();
byte b2 = reader.ReadByte();
return MakeInt(b0, b1, b2);
}
catch { return 0; }
}
int MakeInt(byte b0, byte b1, byte b2) {
return ((b0 << 0x10) | (b1 << 0x08)) | b2;
}
关于c# - FLV车身长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10297172/
我是一名优秀的程序员,十分优秀!