Is there a generic way to get the height and width of a video and other metadata (like the timestamp when the video was taken, etc.) using .NET? I would like to get the size information of common video formats such as .avi
, .mpg
, .mpeg
, .mov
, .asf
etc.
Asked
Active
Viewed 7,780 times
2
-
1Your question is very unclear. What video, in what context? – Joren Sep 19 '09 at 16:14
-
You should post your update as another question, as it's somewhat different from your original post. – Ben Sep 25 '09 at 00:06
1 Answers
2
I don't know if this is the best way to do it, but using DirectX you can use the Video class in the AudioVideoPlayback namespace to get the default size of the video. After creating the Video object, you can get the DefaultSize property, from which the height and width can be obtained.
A simple example:
Video video = new Video(videoPath, false);
Size size = video.DefaultSize;
Console.WriteLine("Width: " + size.Width);
Console.WriteLine("Height: " + size.Height);

Ben
- 1,022
- 1
- 11
- 25
-
thanks, will try it out does it work for HD video too ? .m2ts/.mts etc ? – Kumar Sep 21 '09 at 23:12
-
1I found this useful as well. It may be worth noting that you will need to download the DirectX SDK or DirectX runtime. After doing that, I had to reference the Microsoft.DirectX.AudioVideoPlayback.dll file under c:\windows\assembly\GAC. – Scott Oct 16 '12 at 19:11
-
To reference it: https://stackoverflow.com/questions/4015217/cant-find-references-microsoft-directx-audiovideoplayback-and-microsoft-directx – ono2012 Jun 02 '20 at 13:42