- 1 year ago
How to get missing "Frame height" and "Frame width" properties of a video file in C# using Shell32 (Windows 10)?
To get the "Frame Height" and "Frame Width" properties of a video file in C# using Shell32 on Windows 10, you can use the following code:
csharpusing Shell32;
class Program
{
static void Main()
{
string videoFilePath = "path/to/video/file.mp4"; // Replace with the actual path to your video file
Shell shell = new Shell();
Folder folder = shell.NameSpace(System.IO.Path.GetDirectoryName(videoFilePath));
FolderItem folderItem = folder.ParseName(System.IO.Path.GetFileName(videoFilePath));
string frameHeight = folder.GetDetailsOf(folderItem, 314); // "Frame Height" property
string frameWidth = folder.GetDetailsOf(folderItem, 315); // "Frame Width" property
System.Console.WriteLine("Frame Height: {0}", frameHeight);
System.Console.WriteLine("Frame Width: {0}", frameWidth);
}
}
In this code, we use the Shell32
COM library to interact with the Windows Shell. We create an instance of the Shell
class and then retrieve the Folder
object representing the folder containing the video file.
Using the Folder
and FolderItem
objects, we can access the file's properties. The properties are identified by their property IDs, which are numerical values. In this case, the property ID for "Frame Height" is 314
and the property ID for "Frame Width" is 315
.
By calling the GetDetailsOf
method on the Folder
object and passing the FolderItem
and the property ID as arguments, we can retrieve the corresponding property values.
Replace "path/to/video/file.mp4"
with the actual path to your video file, and you should be able to retrieve the "Frame Height" and "Frame Width" properties of the video file using Shell32 in C#.