Reading/Writing metadata of audio/video files

杀马特。学长 韩版系。学妹 提交于 2019-12-18 13:23:06

问题


I need some help in reading/writing meta data inforamation of audio/vido file. I have searched alot but not find anything thing helpful. Taglib sharp is an open source library that provide help in reading/writing metadata. Using tag lib i'm able to edit some of values but not all like.

TagLib.File videoFile = TagLib.File.Create("test.mp4");
videoFile.Tag.Title = "Test";
videoFile.Tag.Comment = "Nothing";

but i'm unable to edit following properties like Author url, producers etc. How i edit these properties ??


回答1:


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.




回答2:


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");


来源:https://stackoverflow.com/questions/18250281/reading-writing-metadata-of-audio-video-files

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