Skip to content

add duration for all formats#108

Open
karlpip wants to merge 3 commits intodhowden:masterfrom
karlpip:durationAllFormats
Open

add duration for all formats#108
karlpip wants to merge 3 commits intodhowden:masterfrom
karlpip:durationAllFormats

Conversation

@karlpip
Copy link

@karlpip karlpip commented Sep 22, 2024

As i am currently writing a file plugin for a my music server, i needed a library which reads metadata including the duration of a file as fast as possible.
All well established cgo binding based solutions (libvlc, taglib...) I've tested were at least 25% slower than this library.
So i decided to add duration support for this library.

This PR does change the public API of this library in several places, which i guess is not desired. As you have mentioned here #106 (review) you have a solution in mind for this problem. So i thought it might be smarter to wait for you to make a suggestion here after you saw my code and I'll adjust the PR accordingly. I think it wont be a lot of work as the code for the duration reading is already written now.

Technical notes:

  • I deleted the reading of a ID3V1 tag if the filetype is not identified because you might assume that the unknown file is tagged with ID3V1 but i cant just assume it is audio file format XY for reading the duration.
  • MP3 duration calculation is rather an estimation, all my testing mp3's were accurately calculated but it is not exact. One could add the XING header parsing and calculate it more accurately if the header is found but i am not really motivated to invest more time in to the MP3 standard.
  • I renamed Read[Format]Tags to Read[Format]Meta because it now reads the duration too which might be seen as metadata but never as a tag.
  • I've added structs for each format which contains a struct for the tags and a duration field, so the tags struct does not have to be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants