I am using Microsoft.WindowsAPICodePack.Shell.ShellFile
to get the video size (width and height) from a file path.
public Size GetVideoSize(string videoFullPath)
{
if (File.Exists(videoFullPath))
{
ShellFile shellFile = ShellFile.FromFilePath(videoFullPath);
int videoWidth = (int)shellFile.Properties.System.Video.FrameWidth.Value;
int videoHeight = (int)shellFile.Properties.System.Video.FrameHeight.Value;
return new Size(videoWidth, videoHeight);
}
return Size.Empty;
}
The problem is that this method doesn't retrieve the correct size for m4v file. Do you have any suggestions? What can I use in order to get the actual width/height?
Example: I have a m4v video, which has a real size of 856x480
- if I look at the file's properties in Windows explorer, the size is 720x480 (wrong)
- if I open the video in a video player, the video is rendered at the correct size, even if the video details still show a size of 720x480
- if I load the video in a MediaElement control in WPF, I get the correct size, through
mediaElement.NaturalVideoWidth, mediaElement.NaturalVideoHeight
, but the problem is that I need to get the size in a class library which doesn't have any WPF references.