Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

metadata

video

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.

like image 522
Carbongrip Avatar asked Nov 02 '14 02:11

Carbongrip


2 Answers

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/

like image 121
Reticulated Spline Avatar answered Nov 08 '22 18:11

Reticulated Spline


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.

like image 20
xmedeko Avatar answered Nov 08 '22 19:11

xmedeko