Solved

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

Posted on 2009-05-08
1
1,345 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
Comment Utility

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
Viewers will learn how to turn a Live Set into a compressed Live Pack file, and how to install Live Packs. Make: File > Collect All And Save: File > Manage Files: Click Manage Project: Click Create Pack: Select save location: Install: Doub…
Viewers will learn how to use Macros for greater control over Rack parameters in Ableton Live. Group devices into a Rack by selecting them and pressing Command-G (Ctrl-G on PC): Control-click (Right Click on PC) a parameter to access pop-up menu, …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now