I am currently working in this problem for hours now. I have to create a program that when user gets a video from a child window which accesses your hard disk drives, I have to get the frame rate and other properties from that video.
Here’s a sample code of how I’m getting the videos and some of their properties.
SelectDirectoryWindow selectDirectoryWindow = (sender as SelectDirectoryWindow);
if (selectDirectoryWindow.DialogResult.GetValueOrDefault(false))
{
foreach (System.IO.FileInfo fileInfo in selectDirectoryWindow.VideoFiles)
{
VideoFileInfo videoFileInfo = new VideoFileInfo();
videoFileInfo.FileName = fileInfo.Name;
videoFileInfo.Path = fileInfo.FullName;
videoFileInfo.Extension = fileInfo.Extension;
videoFileInfo.FileSize = fileInfo.Length;
switch (videoFileInfo.Extension.ToUpper())
{
case ".WMV":
videoFileInfo.VideoFileType = Constants.VideoFileType.Wmv;
break;
case ".MOV":
videoFileInfo.VideoFileType = Constants.VideoFileType.ProResHq;
break;
case ".MPG":
videoFileInfo.VideoFileType = Constants.VideoFileType.Mpeg2;
break;
case ".ISM":
videoFileInfo.VideoFileType = Constants.VideoFileType.SmoothStreaming;
break;
case ".MP4":
videoFileInfo.VideoFileType = Constants.VideoFileType.iPad;
break;
default:
break;
}
Is there any way I can also get the frame rate, video duration and bit rate from this? What can I do to get the frame rate and bit rate? Thanks in advance.
I have found the answer. There is a ShellFile class on the Microsoft.WindowsAPICodePack.Shell. In there you can get the properties of the video, just give it the source of the file(filepath). And you can get anything from there.
Here’s how I got the Frame Rate.