Carbongrip
Carbongrip

Reputation: 173

C# Reading Video Metadata in Windows (Title,description,year)

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.

Upvotes: 8

Views: 21614

Answers (2)

Reticulated Spline
Reticulated Spline

Reputation: 2012

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

https://web.archive.org/web/20170225230114/https://stackoverflow.com/questions/7396265/c-sharp-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/

Upvotes: 8

xmedeko
xmedeko

Reputation: 7820

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.

Upvotes: 2

Related Questions