【问题标题】:How to get missing "Frame height" and "Frame width" properties of a video file in C# using Shell32 (Windows 10)?如何使用 Shell32(Windows 10)在 C# 中获取缺少的视频文件的“帧高度”和“帧宽度”属性?
【发布时间】:2019-09-18 00:28:35
【问题描述】:

我正在尝试使用 C# 中的 Shell32 确定视频文件的分辨率,但属性返回空字符串,尽管 Windows shell 可以正常显示信息。

请注意,我不能为此任务合并任何第三方库(DirectShow 或其他)。

对于不同的视频文件,此行为仍然存在。很遗憾,here 中提供的答案都没有帮助。

我正在使用以下代码提取信息:

Shell32.Shell shell = new Shell32.Shell();
Shell32.Folder objFolder;

objFolder = shell.NameSpace(Path.GetDirectoryName(videoFile.FullName));
FolderItem objFile = objFolder.ParseName(videoFile.Name);

List<string> arrHeaders = new List<string>();
for (int i = 0; i < 1000; i++) {
  string header = objFolder.GetDetailsOf(null, i);
  if (String.IsNullOrEmpty(header))
    continue;
  arrHeaders.Add(header);
}

var length = objFolder.GetDetailsOf(
  objFile, arrHeaders.FindIndex(h => h == "Length"));
var resWidth = objFolder.GetDetailsOf(
  objFile, arrHeaders.FindIndex(h => h == "Frame width"));
var resHeight = objFolder.GetDetailsOf(
  objFile, arrHeaders.FindIndex(h => h == "Frame height"));

对于以下文件,我希望 resWidth 具有值 "1920"resHeight 具有值 "1080" 但它们都包含空字符串。这两个属性都存在于arrHeaders 中,特别是在我系统上的索引 301 和 303 中。

附带说明,Length 属性按预期工作。

【问题讨论】:

标签: c# windows windows-10 shell32 extended-properties


【解决方案1】:

哇,抱歉。我似乎完全跳过了我错误地枚举索引的事实,因为我跳过了空标题。 ? 问题解决了!

【讨论】:

    猜你喜欢
    • 2016-07-03
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-10
    相关资源
    最近更新 更多