Solved

Is it possible to downsample mp3 files in Java?

Posted on 2006-07-17
6
399 Views
Last Modified: 2008-02-01
I need the ability to downsample an mp3 file in a utility I am writing.  I currently use the tritonus libraries when doing this for .wav files and this works fine.  However when I try to do the same with mp3's I run into many problems.  Is/are there java libraries that have the ability to downsample an mp3 file?  links would be appreciative.

Thanks
0
Comment
Question by:csciguy81
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 17126391
Not sure if JLayer is able to downsample, but have a look : http://www.javazoom.net/javalayer/documents.html
0
 
LVL 2

Accepted Solution

by:
azoapes earned 250 total points
ID: 17128762
Yes, it is possible. Use the lame encoder: http://lame.sourceforge.net/
0
 

Author Comment

by:csciguy81
ID: 17146610
So would it be better to take an mp3, encode it to a wav, then decode back to an mp3 with a lower sample rate?  Can lame take in an mp3 file and spit back out an mp3 file that has been downsampled?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 2

Expert Comment

by:azoapes
ID: 17146904
I think you don't have to convert between WAV at all, just check out the command line for LAME: http://lame.sourceforge.net/using.html

It says also that LAME supports free format encoding and decoding. I can get you exactly the command line for downsampling using LAME if you want, but it is easy if you check the link above!

Good luck.

/Simeon
0
 

Author Comment

by:csciguy81
ID: 17147059
woo. it seems like lame works perfectly.  Now. when I am implementing this in java, is there anything I need to look out for?  Would something like this work?

try {
        String command = commandLine = "lame -b 64 "+file1input+" "+file1output;
        Process child = Runtime.getRuntime().exec(command);    
        child = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    }

Would I need to perform a wait on this process or a destroy?  This method may be called by many users at one time.
0
 
LVL 2

Expert Comment

by:azoapes
ID: 17147111
That should work just fine. Sinci you're catching IOException there should be nothing to worry about. If there are many users, you might want to consider making the execution-code (like the one you posted just above here) in a separate thread, but try it as it is firstly.

/Simeon
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
wordappend challenge 8 172
Adding Namespace to the second node of the xml 16 71
simplest php form 3 77
Beginner to Unreal Engine 4 5 79
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now