读取 Ogg/Flac 文件的标签数据
我正在开发一个从音乐文件中读取标签信息的 C 库。我已经处理了 ID3v2,但我无法弄清楚 Ogg 文件的结构。
我在十六进制编辑器中打开了一个 .ogg 文件,我可以找到标签数据,因为这些数据都是人类可读的。但从文件开头到标签数据的所有内容看起来都是垃圾。这些数据是如何编码的?
我在实际代码中不需要任何帮助,我只需要帮助可视化 Ogg 标头的外观以及它使用的编码,以便我可以阅读它。我想使用一种非 hacky 的方法来读取 Ogg 文件。
我一直在研究 Flac 格式,这很有帮助。
我正在查看的 Flac 文件在“fLac”标识符和人类可读的注释部分之间大约有 350 个字节,并且在我的十六进制编辑器中没有一个是人类可读的,所以我确信必须有一些东西 在那里很重要。
我正在使用 Linux,并且无意移植到 Windows 或 OS X。因此,如果我需要使用仅限 glibc 的函数来转换编码,我可以接受。
I'm working on a C library that reads tag information from music files. I've already got ID3v2 taken care of, but I can't figure out how Ogg files are structured.
I opened a .ogg file in a hexeditor and I could find the tag data because that was all human readable. But everything from the beginning of the file to the tag data looked like garbage. How is this data encoded?
I don't need any help in the actual code, I just need help visualizing what a Ogg header looks like and what encoding it uses so I that I can read it. I'd like to use a non-hacky approach to reading Ogg files.
I've been looking at the Flac format, which has been helpful.
The Flac file I'm looking at has about 350 bytes between the "fLac" identifier and the human readable Comments section, and none of it is human readable in my hex editor, so I'm sure there has to be something important in there.
I'm using Linux, and I have no intention of porting to Windows or OS X. So if I need to use a glibc only function to convert the encoding, I'm fine with that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ogg 文件格式记录在此处。根据您的要求,有一个非常好的图形可视化和详细的书面描述。
您可能还想查看 libogg,它是一个用于读写 Ogg 的开源 BSD 许可库文件。
The Ogg file format is documented here. There is a very nice graphical visualization as you requested with a detailed written description.
You may also want to look at libogg which is a open source BSD-licensed library for reading and writing Ogg files.
正如您提供的链接中所述,以下元数据块可能出现在“fLaC”标记和 VORBIS_COMMENT 元数据块之间。
在上面的描述之后,还有每个块的格式规范。该链接还说
那么,你还缺少什么?你说
当它们已经存在时,为什么要重新编写一个库来做到这一点?
As is described in the link you provided, the following metadata blocks can occur between the "fLaC" marker and the VORBIS_COMMENT metadata block.
Just after the above description, there's also the specification of the format of each of those blocks. The link also says
So, what are you missing? You say
Why re-write a library to do that when they already exist?