Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-05-08
1
Medium Priority
?
1,389 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 750 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The advancements in today's technology are unparalleled. Much of the technology that we have could not have been imagined twenty years ago. One of the latest additions to the list of technological advances is virtual reality. Virtual reality has an …
Users will learn how resize a batch of photos from a single command in Photoshop via Photoshop's Image Processor. Open up an Image you'd like to resize in Adobe Photoshop: Adjust the image size according to your preferences. Image > Adjustments > …
Viewers will learn the basics of making and using Impulse Kits in Ableton Live. Load new Impulse into an empty MIDI track: Fill the 8 empty sample slots with drum samples: Adjust parameters to tailor each sound as desired: Proceed to create be…

722 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