gpt4 book ai didi

c++ - 标签库 : how to edit Album Artist?

转载 作者:行者123 更新时间:2023-11-30 01:59:00 24 4
gpt4 key购买 nike

如何使用 TagLib 库修改 MP3 文件的“专辑艺术家”字段?有没有类似的东西:

f.tag()->setArtist("blabla");

?

最佳答案

ID3v2 实际上并不支持名为“专辑艺术家”的字段。 iTunes 使用 TPE2 框架,应该是:

TPE2
The 'Band/Orchestra/Accompaniment' frame is used for additional information about the performers in the recording.

有关框架的完整列表,请参阅 http://id3.org/id3v2.3.0#Declared_ID3v2_frames .

要用 TagLib 编写它,就可以做到这一点:

#include <mpegfile.h>
#include <id3v2tag.h>
#include <textidentificationframe.h>

int main()
{
TagLib::MPEG::File file("foo.mp3");
TagLib::ByteVector handle = "TPE2";
TagLib::String value = "bar";
TagLib::ID3v2::Tag *tag = file.ID3v2Tag(true);

if(!tag->frameList(handle).isEmpty())
{
tag->frameList(handle).front()->setText(value);
}
else
{
TagLib::ID3v2::TextIdentificationFrame *frame =
new TagLib::ID3v2::TextIdentificationFrame(handle, TagLib::String::UTF8);
tag->addFrame(frame);
frame->setText(value);
}

file.save();

return 0;
}

如果你只是想删除框架,你可以简单地做:

TagLib::MPEG::File file("foo.mp3");
TagLib::ID3v2::Tag *tag = file.ID3v2Tag();

if(tag)
{
tag->removeFrames("TPE2");
file.save();
}

关于c++ - 标签库 : how to edit Album Artist?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16628798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com