Solved

Is it possible to downsample mp3 files in Java?

Posted on 2006-07-17
6
394 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
Comment Utility
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
Comment Utility
Yes, it is possible. Use the lame encoder: http://lame.sourceforge.net/
0
 

Author Comment

by:csciguy81
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 2

Expert Comment

by:azoapes
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article will show, step by step, how to integrate R code into a R Sweave document
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

743 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

17 Experts available now in Live!

Get 1:1 Help Now