了解ID3v2.3标签标头(mp3)的“大小"部分 [英] Understanding the 'size' part of ID3v2.3 tag header (mp3)

查看:145
本文介绍了了解ID3v2.3标签标头(mp3)的“大小"部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Howdy,

我正在尝试从mp3文件中读取ID3元数据.以前没有做过这样的事情.通过查看ID3.org上的标准并使用Google,我似乎能够获得文件标识符"("ID3"),版本"和标志"信息.但是,我似乎无法获得尺寸"部分.我的意思是,我得到了一些东西,但是我似乎无法...转换数据,因此对我来说是有用的信息.例如,以KB为单位的大小是多少?

这是我尝试过的内容:

Howdy,

I'm trying to read the ID3 metadata from an mp3 file. Haven't done anything like this before. From looking at the standard on ID3.org and using Google, I seem to able to get the 'file identifier' ("ID3"), 'version' and 'flags' info OK. But, I can't seem to get the 'size' part. I mean, I'm getting something, but I can't seem to... convert the data so it is useful information for me. For example, whats the size in KB or something.

Here's what I've tried:

// storage section
byte[] tag = new byte[3];
byte[] version = new byte[2];
byte[] flags = new byte[1];
byte[] size = new byte[4];

// reading section
BinaryReader br = new BinaryReader(File.Open(tmpfile, FileMode.Open));
br.Read(tag, 0, tag.Length);
br.Read(version, 0, version.Length);
br.Read(flags, 0, flags.Length);
br.Read(size, 0, size.Length);

// output section
Console.WriteLine(BitConverter.ToInt32(size, 0));
Console.WriteLine(BitConverter.ToString(size));
for (int i=0; i<size.Length; i++)
{
    Console.Write(Convert.ToString(size[i], 2));
}

我得到的结果是:

1259339776
00-00-10-4B
00100001001011

我想,我只是不理解转换方法(erm,除其他外,似乎...).但是话又说回来,我认为这些结果最初并不是正确的尺寸表示,因此无法从中得出转换结果.我只是想知道/输出文件中整个ID3元数据所占用的空间.

希望有人能解释这种情况,我似乎无法破解. hr class ="sig"> Beginner

The results I get are:

1259339776
00-00-10-4B
00100001001011

I guess, I'm just not understanding the conversion method (erm, amongs other things it seems...). But then again, I think these results aren't correct representations of the size in the first place, so it's impossible to figure out the conversion from them. I just want to be able to tell/output, how much space the whole ID3 metadata takes up in the file.

Hopefully somone can explain this situation me, I can't seem to crack it.


Beginner

推荐答案

似乎ID3使用大尾数字节顺序,而BitConverter假定小尾数.您可以在此处 http://www.yoda.arachsys.com/csharp/miscutil/找到支持大端字节的/a>

Seems like ID3 uses big endian byte order, whereas the BitConverter assumes little endian. You can find one with support for big endian here http://www.yoda.arachsys.com/csharp/miscutil/


这篇关于了解ID3v2.3标签标头(mp3)的“大小"部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆