Code Monkey home page Code Monkey logo

Comments (4)

mackron avatar mackron commented on June 3, 2024 1

This is easy done. Use drmp3_get_pcm_frame_count() and derive it from the sample rate:

lengthInSeconds = drmp3_get_pcm_frame_count(&mp3) / mp3.sampleRate;

The example above calculates the length in seconds. From there it's a trivial conversion to milliseconds. The sample rate can be retrieved directly from the drmp3 struct.

from dr_libs.

ericoporto avatar ericoporto commented on June 3, 2024

I saw two additional cases, one in al_mp3, where is looks like a header exists with the information ready in xing header. The other is a case where it's a variable rate but this header it seems is not available or the person was not aware, which is reported here lieff/minimp3#54. I was just looking for a method that could check all of these and give me the direct answer.

from dr_libs.

mackron avatar mackron commented on June 3, 2024

So dr_mp3 will always iterate over the entire file like in that minimp3 issue you mentioned. That will give you an accurate frame count, but it comes at the expense of a slow processing time. There's no header interrogation going on in dr_mp3, though I would like to support that eventually.

Another potential issue is when the sample rate changes between MP3 frames. The sample rate used by dr_mp3 is always the sample rate of the first MP3 frame. I think this is quite uncommon though? Regardless, I have little interest in supporting that scenario.

from dr_libs.

ericoporto avatar ericoporto commented on June 3, 2024

Thanks for the information. :)

from dr_libs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.