question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support calculating approximate duration

See original GitHub issue

Giving the duration: true option makes all media files be fully scanned to calculate their accurate duration, but when a large number of files should be handled, it is enough to get approximate duration of songs; most clients to play them do not trust what the server gives anyway.

How about adding an option like approximate: true to duration: true for approximate duration? As I recall, an old version of musicmetadata did that by assuming CBR when the first three frames have the same bit-rate; I ported that to mp3-duration (https://github.com/mycoboco/mp3-duration/commit/abdb1bca7d9739dbff1b99479b84c811d2bc6f12).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Borewitcommented, Aug 24, 2017

That could very well be the reason.

On a good quality (using a recent Lame encoder) MP3 encoded file, it will do the duration calculation on the VBR/Xing/Info header. That header specifies the number of frames.

I just removed a silly rounding from that calculation. It is pretty accurate only thing what is missing is subtracting the “empty” space in the very last frame.

0reactions
Borewitcommented, Sep 4, 2017

@mycoboco, thanks for your reply and promising the benchmark.

Feel free to open an issue for the remaining 6 files or re-open this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Approximate modified duration (ApproxModDur) - PrepNuggets
Modified duration of a bond that is calculated using the approximate method by calculating the change in prices for a small change in ......
Read more >
Duration Formula (Excel Examples) | Calculate Duration of Bond
The formula for the duration is a measure of a bond's sensitivity to changes in the interest rate, and it is calculated by...
Read more >
Duration Definition and Its Use in Fixed Income Investing
Duration indicates the years it takes to receive a bond's true cost, weighing in the present value of all future coupon and principal...
Read more >
DURATION function - Microsoft Support
Duration is defined as the weighted average of the present value of cash flows, and is used as a measure of a bond...
Read more >
Bond Duration Calculator - Exploring Finance
The Bond Duration Calculator can be used to derive the duration of a bond: Number of Years to Maturity: Yield or Market Rate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found