Hi guys,
I am just starting with DirectShow.NET, and I am trying to get the length (in seconds) of an audio file. The audio may be .mp3, .wav, .aac, or .m4a.
Can I get this information using DirectShow, or do I need some other APIs?
Hi guys,
I am just starting with DirectShow.NET, and I am trying to get the length (in seconds) of an audio file. The audio may be .mp3, .wav, .aac, or .m4a.
Can I get this information using DirectShow, or do I need some other APIs?
yes you can do this with DirectShow. There are a variety of ways to do this. One way is to query the IMediaSeeking interface on the graph object, and then call the GetDuration method on this interface.
GetDuration returns a 64bit integer value for how long it would take to play the file.
You will need to call the GetTimeFormat
method to find out what units the duration is in. The most likely default value is TIME_FORMAT_MEDIA_TIME which is 10ths of a microsecond.
IN that case you would divide the duration by 10*1000*1000 to get seconds.
You can also call SetTimeFormat
before calling GetDuration
if you want to force the units.