简体   繁体   English

如何获取flac和ogg的音频文件元数据容器数据

[英]How to get audio file metadata container's data for flac and ogg

Is there a command to tell me what type of metadata container is using a file?是否有命令告诉我使用文件的元数据容器类型?

Something like: command myfile.flac saying: vorbis comment or id3v2 .类似于: command myfile.flac说: vorbis commentid3v2

Warning: One audio file can have multiple metadata containers.警告:一个音频文件可以有多个元数据容器。 So finding vorbis comment doesn't mean there is no id3 tags.所以找到 vorbis 评论并不意味着没有 id3 标签。 Reminder: flac and ogg should be used with vorbis comment.提醒:flac 和 ogg 应与 vorbis 注释一起使用。

Vorbis comment沃比斯评论

Flac弗拉克

metaflac --list myfile.flac

It will print a lot of info for each block.它将为每个块打印大量信息。 Here is the answer:这是答案:

METADATA block #2
  type: 4 (VORBIS_COMMENT)

To install metaflac: sudo apt install flac .要安装 metaflac: sudo apt install flac

Ogg奥格

vorbiscomment file.ogg

It will output something like:它会输出如下内容:

encoder=Lavc57.107.100 libvorbis
TRACKNUMBER=1
title=My file title
...

To install: sudo apt install vorbis-tools安装: sudo apt install vorbis-tools

ID3 ID3

Well, the best thing I found is a python library: mutagen .好吧,我发现的最好的东西是一个 python 库: mutagen For example, in your python file you can write:例如,在您的 python 文件中,您可以编写:

from mutagen.id3 import ID3NoHeaderError, ID3

try:
    tags = ID3("path/to/myfile.ogg")
    print("ID3 tags found: ", tags)
except ID3NoHeaderError:
    print("No ID3 tags")

Output for file with ID3 tags: ID3 tags found: {'TIT2': TIT2(encoding=<Encoding.UTF8: 3>, text=['my new title'])} .带有 ID3 标签的文件的输出: ID3 tags found: {'TIT2': TIT2(encoding=<Encoding.UTF8: 3>, text=['my new title'])} It works also for flac files.它也适用于 flac 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM