[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Is it possible to downsample mp3 files in Java?

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
csciguy81
Asked:
csciguy81
  • 3
  • 2
1 Solution
 
bpmurrayCommented:
Not sure if JLayer is able to downsample, but have a look : http://www.javazoom.net/javalayer/documents.html
0
 
azoapesCommented:
Yes, it is possible. Use the lame encoder: http://lame.sourceforge.net/
0
 
csciguy81Author Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
azoapesCommented:
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
 
csciguy81Author Commented:
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
 
azoapesCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now