Solved

C# retrieve the duration of media files such as .avi, wmv, wma, wav, etc

Posted on 2009-05-08
1
1,357 Views
Last Modified: 2012-05-06
Is there a way of retrieving the duration of media files (avi, wmv, wma, wav, etc) from a command line application? At the moment I can use an instance of AxWindowsMediaPlayer, but this only seems to work for audio .wma.
AxWMPLib.AxWindowsMediaPlayer objPlayer = new AxWMPLib.AxWindowsMediaPlayer();
               WMPLib.IWMPMedia media = objPlayer.newMedia(strMediaFilePath);
                dblDuration = media.duration;

Open in new window

0
Comment
Question by:ttnetworks
1 Comment
 
LVL 12

Accepted Solution

by:
williamcampbell earned 250 total points
ID: 24337889

With DirectShow, you can use IGraphBuilder::RenderFile() to create a graph
and then use IMediaSeeking::GetDuration().

Otherwise, you can use the IMediaDet interface (which does the above
internally).

So you could create a C++ DLL and then use p/Invoke too grab the result form C# land.

Google the above and you may find some code.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
You may or may not be familiar with Kodi (http://www.kodi.tv) the open source software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS, and Android.  Kodi which started off as X-Box Media Center (XBMC) many years…
This video will give a brief orientation and organization of Logic Pro X, and how to access different work spaces quickly with keyboard shortcuts.
Viewers will learn the basics of creating custom device Racks in Ableton Live. Place instrument(s) and effects onto a track, and select them all by holding the Shift key and clicking on the device title bars: Group them by typing Command-G (Ctrl-G…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question