C# Reading Video Metadata in Windows (Title,descri

2019-06-22 02:59发布

Hey everyone just trying to make a program that browses video files and reads the title and description from the files metadata. I found some docs from microsoft here giving whats needed but how do I access these functions? what using namespaces are needed in c#? I would love any help that can be provided.

2条回答
闹够了就滚
2楼-- · 2019-06-22 03:12

In that link you posted, scroll to the bottom and click "Shell Metadata Providers". There's more more information and some sample C++ code.

Here are some other relevant links:

Reading/Writing metadata of audio/video files

http://www.codeproject.com/Articles/14535/Accessing-WMF-metadata-with-C

https://social.msdn.microsoft.com/Forums/pt-BR/0f36a3b2-4d3d-4842-88a4-bea493bbbace/read-video-filemov-avi-mpg-etc-meta-data?forum=csharpgeneral

C# to read properties of video files?

Sorry I can't give you anything more concrete, however it looks like some tag libraries (i.e. for reading MP3 metadata) may work as well, as the metadata for videos seems to be stored in a similar, if not identical, format. That being said, you can give TagLib# a shot.

https://www.nuget.org/packages/taglib/

查看更多
Melony?
3楼-- · 2019-06-22 03:16

I've made a simple C# code (portable to Unity, too) csatomreader. It's optimized for speed and can read the atoms over HTTP, too.

E.g. Get title:

using (FileStream stream = new FileStream(fileName, FileMode.Open))
{
    var mp4Reader = new AtomReader(stream);
    string value = mp4Reader.GetMetaAtomValue(AtomReader.TitleTypeName);
    Console.WriteLine($"{atomTypeName}: {value}");
}

If you need to get more metadata values at once, then iterate over ParseAtoms(), e.g. see the GetMetaAtomValue() source.

查看更多
登录 后发表回答