Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:55:05+00:00 2026-05-23T21:55:05+00:00

Having an awful time trying to get the accurate time for a set of

  • 0

Having an awful time trying to get the accurate time for a set of MP3s. I have these following properties that are generated using the MP3SPI 1.9.5 library.

//      mp3.crc=true
//      mp3.copyright=true
//      mp3.padding=false
//      mp3.channels=1
//      mp3.version.mpeg=2.5
//      mp3.length.bytes=6425480
//      mp3.framerate.fps=27.777779
//      mp3.framesize.bytes=140
//      duration=1606356000
//      mp3.version.layer=3
//      mp3.length.frames=44621
//      mp3.frequency.hz=8000
//      mp3.header.pos=0
//      mp3.bitrate.nominal.bps=16000
//      mp3.vbr.scale=0
//      mp3.version.encoding=MPEG2DOT5L3
//      mp3.mode=3
//      mp3.vbr=false
//      mp3.original=false

Now the file I am reading has a duration of 47:35 as reported by iTunes, and 48:50 using Mac Preview.

When I get the duration in Java using the library I get 26:46:

AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(f);
            Map<?, ?> properties = ((TAudioFileFormat) fileFormat).properties();
            String key = "duration";
            long duration = ((Long) properties.get("duration")) / 1000;
            {
                String frameBased = String.format("Duration Tag: %d hours, %d min, %d sec",
                        TimeUnit.MILLISECONDS.toHours(duration),
                        TimeUnit.MILLISECONDS.toMinutes(duration),
                        TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))
                    );
                    System.out.println(frameBased);
            }

I’m not having much luck, so I was wondering if I’m doing something dumb, or if I can use the information within the MP3 tags to calculate my actual length? Given iTunes is reporting it correctly I assume I should be able to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:55:05+00:00Added an answer on May 23, 2026 at 9:55 pm

    Given iTunes is reporting it correctly I assume I should be able to.

    One fail-safe way to determine the length of the track is to convert it into a standard AudioInputStream and then measure the AIS.

    Or, as per the comment of @Kilian Foth:

    Unfortunately, that is also the only fail-safe way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an awful time trying to get these triangle strips to show up.
I am having an awful time trying to come up with a good solution
I'm having an awful time trying to use a library to parse an XML
I'm having an awful time trying to understand what my validation method is having
I'm having awful problems with this. I have a MapView, in my activity I
I am using PHPStorm and have written a class that utilises the SimpleXML class.
I am having awful trouble getting functional tests to work when using devise and
Having spent some time working on data warehousing, I have created both ETL (extract
I've been having the most AWFUL time integrating MailChimp into a site I'm designing!
Having a issue where all mobile devices is zoomed 50% in at start. That

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.