.NET, C#, DirectX, WMV

Determine a video size and duration


You can determine the size and duration of a video using DirectX.
After installing DirectX on your development box, add a reference to Microsoft.DirectX.AudioVideoPlayback assembly.

Then, create an instance of a Video class and pass the name of the movie file you want to load (I tested it using a WMV file).

Example:

Microsoft.DirectX.AudioVideoPlayback.Video video = new Microsoft.DirectX.AudioVideoPlayback.Video(path);
StringBuilder sb = new StringBuilder();
sb.Append(video.Caption);
sb.Append("\r\n");
sb.Append(video.Size.Width.ToString());
sb.Append(
"\r\n");
sb.Append(video.Size.Height.ToString());
sb.Append(
"\r\n");
sb.Append(video.Duration.ToString());
textBox1.Text = sb.ToString();

Advertisements

7 thoughts on “Determine a video size and duration”

  1. Any idea how I can implement this code in an ASP or ASPX file so all I have is a function where I specify the file path and all I get is the video duration? Thanks 🙂

  2. the code don’t runs ASP.NET boys

    using Microsoft.DirectX.AudioVideoPlayback;

    Video vvideo = new Video(video.f_VideoAdiGetir(fuVideo.FileName.ToString()));
    StringBuilder sb = new StringBuilder();
    sb.Append(duration.toString());
    error message;

    “Installed an access attempt was made to the application domain.”

    “vvideo” instance is created error msj ://

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s