Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/21/d38531796/htdocs/jose/smfforum/Sources/Subs.php on line 3825
mp3 duration

General Category > General Discussion

mp3 duration

(1/3) > >>

Juergen Kuehlwein:
Hi José,

Merry Christmas!

Found some time to play with my music collection. For playing mp3 files i use directshow, which works quite well for all music formats (.mid, .wav, .mp3, ...) - except for one thing, duration. I can get the time an audio file is expected to play from IMediaPosition or IMediaSeeking but in both cases the returned time is wrong for mp3 files. Interestingly enough Windows shows the correct time. The tooltip when hovering or the details tab of file properties (right click -> properties -> details tab) show the correct time.

So Windows somehow knows (or calculates) it. But how? How does Windows do that, and how can i make use of it? I cannot find an appropriate API nor am i able to find some COM code doing it. I found one thing, which looks promising here ( I cannot find IStorageItemExtraProperties and related classes or interfaces in your includes. The required information might not be found in musicproperties but maybe in some other file property around here - this is my best bet.

Do you know how to retrieve these properties in PB?



Patrice Terrier:
and read this

Better to use Bass.dll, or the Media Foundation API.

Juergen Kuehlwein:

Merry Christmas to you as well!

Thanks for your reply. I read about IMediaSeeking being a better choice, but for me (Windows 10), it returns the same (wrong) result as IMediaPosition. Strange that this bug hasn´t be fixed as of now and that you must do it yourself as your link proposes.

I know and already used Bass.dll (a great piece of software btw.), but i wanted to be independent of third party software. And obviously Windows can do what i want.

Juergen Kuehlwein:
In the meantime i found Jim Fritts´ PB source code ( and could adapt it to show the duration - tada, now it´s correct.

Unfortunately the Media Foundation API seems a rather complicated way of retrieving this little piece of data and it requires Windows 8 or higher - i was hoping for an easier solution.

Juergen Kuehlwein:
I know that the duration information displayed by Windows doesn´t come from ID3 tags, because, when i remove these tags (i verfied removal with a hex editor), the duration displayed stays the same. Mp3tag (a program for showing and editing id3 tags) shows the correct duration with and without tags in Windows 7 and 10. So there must be some other (working) method than Media foundation.


[0] Message Index

[#] Next page

Go to full version