如何从视频文件的"媒体创建"列中提取日期?

Jas*_*uli 9 .net c# video extract

我需要使用C#从"Media Created"列中提取日期(在下面的示例照片中以绿色突出显示).

在我的示例中,"Media Created"和"Date"列完全相同.但是,有几种情况并非如此."媒体创建"列包含实际录制视频的正确日期.

看这个专栏?

这是我用来获得它的功能.感谢Aziz指出我正确的方向:

Shell shell = new ShellClass();
Folder folder = shell.NameSpace(_File.DirectoryName);
FolderItem file = folder.ParseName(_File.Name);

// These are the characters that are not allowing me to parse into a DateTime
char[] charactersToRemove = new char[] {
    (char)8206,
    (char)8207
};

// Getting the "Media Created" label (don't really need this, but what the heck)
string name = folder.GetDetailsOf(null, 191);

// Getting the "Media Created" value as a string
string value = folder.GetDetailsOf(file, 191).Trim();

// Removing the suspect characters
foreach (char c in charactersToRemove)
    value = value.Replace((c).ToString(), "").Trim();

// If the value string is empty, return DateTime.MinValue, otherwise return the "Media Created" date
return value == string.Empty ? DateTime.MinValue : DateTime.Parse(value);
Run Code Online (Sandbox Code Playgroud)

Azi*_*ziz 5

可以使用Folder.GetDetailsOf()方法获取扩展文件属性。根据此线程,可以使用 177 的属性 ID 检索媒体创建日期


Raf*_*ger 5

还有另一种检索数据的方法,即使用Microsoft.WindowsAPICodePack.Shell命名空间。

ShellObject shell = ShellObject.FromParsingName(path);

var data = shell.Properties.System.Media.DateEncoded;
Run Code Online (Sandbox Code Playgroud)

  • 好点子。对于 Gopro MP4 文件,“System.Media.DateEncoded”属性返回媒体的创建日期。 (2认同)