I'm using TagLib# to get ID3 tag data from some MP3s, but what I can't seem to do is find the length of the MP3. How can I find the length of an MP3 in C#?
Asked
Active
Viewed 7,238 times
1 Answers
12
TagLib# exposes this information TagLib.File.Properties.Duration
-
That was easy to get it to work, but it's returning about 70% of the real duration of all the files I tried it with. – Pablo Fernandez Dec 30 '09 at 21:33
-
I can't say I've tested it tbh so you could be right. I get the impression calculating duration from headers is an inexact science. – dwynne Jan 07 '10 at 15:37
-
I've tested taglib-sharp and it was max. 1 seconds wrong. this library does not use the file length to get the duration, so i'll definitely go with this. – aslı Mar 21 '10 at 19:41
-
I use NAudio instead to get proper duration for media files; the obtained information seem to be correct since it allowed me to implement a functionality that can "guess" a discid from a set of mp3 files which I can use to query album information from freedb... – Matze Mar 24 '16 at 08:50