Solved

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

Posted on 2009-05-08
1
1,382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to download, install, and customize fonts inside Adobe Illustrator CS6. To install and use a font: Go to dafont.com and download a premade font : Unzip it, and open it up by double-clicking: Press “Install This Font” in…
This video will demonstrate how to customize windows, tools, and control bars, and save them as screen sets. Open and resize windows: Customize the toolbar: Customize the control bar: Customize your tool selections: Your screen set is alread…

630 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