解码长ID3V2帧
本文关键字:ID3V2 解码 | 更新日期: 2023-09-27 17:59:39
因此,我正在编写一个有趣的程序来收集存储在ID3标签中的MP3信息。(ID3v1很琐碎,这很麻烦!)
我使用的一般过程是读取FrameID(4个字节),然后读取Length(4字节),再读取Data(Length bytes)。
读取Length时,它是一个Syncsafe整数,因此基本上每个字节的最高位应该是0。对于小数据帧来说,这似乎很好,但当它们变长时,偶尔我会在长度字段中遇到一个字节,它的顶部位为1。根据ID3规范的惯例,我应该忽略这一点,但这样做会导致算法出错,只得到部分标记。
特别是标签的frhed转储:
COMM<bh:00><bh:00><bh:00><bh:c6><bh:00><bh:00><bh:00>eng<bh:00>ABC123 ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT KYLE
在这一点上,长度是$000 00 c6,作为BigEndian int,它是198。从技术上讲,这就是这里标签的长度。但是,二进制文件中的c6是1000110。同步安全算法对第一位进行核处理,然后计数变为70,这是不正确的。我已经得到了Winamp 2.95和iTunes 10这样做的帧长度。我不明白。我应该寻找一个条件来安全地同步整数,还是在阅读这些帧时保持原样?
源代码:
FileStream fs = new FileStream(@"D:'commtag.dat",FileMode.Open,FileAccess.Read);
string frameID = ID3v2.ReadStream(fs, 4);
int i = ID3v2.ReadBEInt32(fs);
int j = ID3v2.UnSyncSafe(i);
[...]
public static int ReadBEInt32(Stream mp3File) {
byte[] buffer = new byte[4];
mp3File.Read(buffer, 0, 4);
UInt32 rawInt = BitConverter.ToUInt32(buffer, 0);
//if the endianness is not BigEndian, as provided in the ID3 tag, convert it
if(BitConverter.IsLittleEndian) {
rawInt = (rawInt >> 24) |
((rawInt << 8) & 0x00FF0000) |
((rawInt >> 8) & 0x0000FF00) |
(rawInt << 24);
}
byte mask = 0x7F;
return (int)rawInt;
}
public static int UnSyncSafe(int inData) {
int outData = 0, mask = 0x7F000000;
while(mask > 0) {
outData >>= 1;
outData |= inData & mask;
mask >>= 8;
}
return outData;
}
在运行该示例之后,i和j的值分别为198和70。
这是完整的标题(frhed dump,它进入MP3标题的开头一点):
ID3<bh:03><bh:00><bh:00><bh:00><bh:00><bh:10><bh:1d>TENC<bh:00><bh:00><bh:00><bh:01>@<bh:00><bh:00>WXXX<bh:00><bh:00><bh:00><bh:02><bh:00><bh:00><bh:00><bh:00>TCOP<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TOPE<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TCOM<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TCON<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TRCK<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TYER<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TALB<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TPE1<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>TIT2<bh:00><bh:00><bh:00><bh:01><bh:00><bh:00><bh:00>COMM<bh:00><bh:00><bh:00><bh:d3><bh:00><bh:00><bh:00>eng<bh:00>ABC123 ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT ID3v2COMMENT KYLE I AM ITUNES<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:ff><bh:fb><bh:b2><bh:00><bh:00><bh:00><bh:04><bh:88>
示例中的标记是2.3版本。同步安全整数通常不用于2.3帧,仅用于标记标头。在2.4中,在报头和帧中都使用了同步安全整数。
ID3 2.3帧规格
堆栈溢出问题
ID3v2的每个版本存储帧头的方式都不同。
- ID3v2.2帧头有6个字节长,最后3个字节是大端无符号整数
- ID3v2.3帧头为10字节长,第二个4字节为大端无符号整数。当然,如果ID3v2标签是不同步的,那么可能会有额外的字节
- ID3v2.4帧头是10字节长,第二个4字节是大端非同步无符号整数。当然,除非媒体播放器有缺陷
这是我在库中使用的代码:FrameHeader.cs Line 145
输入本质上是一个已经删除了任何未同步字节的字节数组。