Get a Video File’s Details Using Windows

December 7, 2008 | By | 9 Comments

I searched alot for a way to get details of a video file, without the need of a third party component. Im developing a video library on my free time, and I wanted the user to get this data automatically after selecting the video. The class uses shell32.dll which is what Windows Explorer uses to get the video details, and is available in every Windows installation. I tested my app on Windows XP and Vista. So to use this dll just open the Add Reference dialog box, select the COM tab, select Microsoft Shell Controls And Automation and click OK.

An example that uses the class:

Filed in: ASP.NET, WinForms | Tags: ,

Comments (9)

  1. Satya

    Hi Amgad,

    This code works fine if we have .wmv and .avi video file. How about .mpg file formats which does not have these values as file properties. How can we extract similar properties of video files with different formats (say .mpg, .mp4, .swf etc).


  2. Hello Satya,
    Actually this depends on the video codecs installed, and how well they are programmed. For example if DivX is not installed and you try to access an .avi file that is DivX encoded the properties will not show up nor will the thumbnail preview. When I wrote this post I had a collection of codecs installed(I think it was called K-Lite or something close to it) which enabled me to see thumbnail previews and video properties from Windows Explorer of .mpg and .mp4 files, and this code worked fine with these files. But I think to get .swf details you will need a library from Adobe or a 3rd party.

  3. Rafal B

    Dude, thanks, I really needed that, although framerare is 265 and not 264!

  4. Thank you Rafal for pointing that out. I will fixed it now.

  5. Dani

    And do you know how to get the video resolution (frame width and height) that will work on Macintosh?

  6. Dani

    Can I use some kind of a ffmpeg mono wrapper to get the video resolution on Macintosh?

  7. Dani

    Can I use some kind of a ffmpeg mono wrapper to convert videos?

  8. Hello Dani,
    I didnt try mono on mac, but you could try:

  9. nitin

    hello sir,
    thanks for this code i use this code i find these properties but problem is that i donot get the audiosample rate and channel of video file ,i have lot of search in google but nothing happen .how to find the audio sample rate nad channels of video files ????please help me….???plzzzzzzzzzzzzz

Leave a Reply

Trackback URL | RSS Feed for This Entry