解码长 ID3V2 帧
Posted
技术标签:
【中文标题】解码长 ID3V2 帧【英文标题】:Decoding Long ID3V2 Frames 【发布时间】:2011-06-19 07:03:19 【问题描述】:所以,我正在编写一个有趣的程序来收集存储在 ID3 标签中的 MP3 信息。 (ID3v1很琐碎,这很麻烦!)
我使用的一般过程是读取 FrameID(4 个字节),然后是 Length(4 个字节),然后是 Data(Length Bytes)。
读取 Length 时,它是一个 Syncsafe 整数,所以本质上每个字节中的最高位应该是 0。这对于小数据帧来说似乎很好,但是当它们变长时,偶尔我会遇到一个字节在最高位为 1 的长度字段中。按照 ID3 规范的约定,我应该忽略该位,但这样做会导致算法搞砸并且只能得到部分标签。
特别是标签的fhed转储:
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
此时,长度为$00 00 00 c6,作为BigEndian int 为198,这在技术上是此处标记的长度。但是,二进制中的 c6 是 11000110。同步安全算法核对了第一位,然后计数变为 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。
这是完整的标题(fred 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>
【问题讨论】:
【参考方案1】:您示例中的标记是 2.3 版。 2.3 帧中通常不使用同步安全整数,仅在标签头中使用。在 2.4 中,标头和帧都使用同步安全整数。
ID3 2.3 frame spec
*** question
【讨论】:
你必须小心这个。虽然 ID3v2.4 帧应该是同步安全的,但我已经看到 iTunes 在 2.4 中使用普通整数写入图像帧。【参考方案2】:每个版本的 ID3v2 存储帧头的方式都不同。
ID3v2.2 帧头长 6 个字节,最后 3 个字节是大端无符号整数。 ID3v2.3 帧头长 10 个字节,第二个 4 个字节是一个大端无符号整数。当然,如果ID3v2标签不同步,可能会有额外的字节数。 ID3v2.4 帧头长 10 个字节,第二个 4 个字节是大端非同步无符号整数。当然,除非媒体播放器有缺陷。这是我在库中使用的代码:FrameHeader.cs Line 145
输入本质上是一个字节数组,已经删除了任何不同步的字节。
【讨论】:
以上是关于解码长 ID3V2 帧的主要内容,如果未能解决你的问题,请参考以下文章