Reading/Writing metadata of audio/video files

馋奶兔 提交于 2019-11-30 09:38:10

I've never done this for video files before but I have for mp3 files. You can get access to those frames like this:

TagLib.File file = TagLib.File.Create(mp3FileName);
file.Tag.Title = "some title"; // you've got this
TagLib.Id3v2.Tag tag = (TagLib.Id3v2.Tag)file.GetTag(TagTypes.Id3v2);
tag.SetTextFrame("WOAR", "some url"); // WOAR = Official artist/performer webpage
file.Save();

You can find a list of the text frame identifiers at Wikipedia: ID3v2 Frame Specification (Version 2.3)

I don't know if video files give you the same range of frames that ID3 does, though notice that Wikipedia also says (Implementation in non-mp3s and alternatives)

MP4 also allows the embedding of an ID3 tag, and this is widely supported.

So I would guess this also works for mp4 files like you're trying.

You will need to use AppleTag. This will work. For mp4 file you have to write value into dashbox. Like this:

TagLib.File videoFile = TagLib.File.Create("test.mp4");
TagLib.Mpeg4.AppleTag customTag = (TagLib.Mpeg4.AppleTag)f.GetTag(TagLib.TagTypes.Apple);
customTag.SetDashBox("Producer","Producer1", "value");
f.Save();
f.Dispose();

And you can get the value like this:

var tokenValue = customTag.GetDashBox("Producer", "Producer1");
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!