Reputation: 5086
Is it possible using Java to convert a real time audio stream from the mixer to MP3?
Upvotes: 4
Views: 12359
Reputation: 2505
Use Xuggler to do it. It's free, and open source (LGPL), and uses libmp3lame under the covers. And the MediaTool API in Xuggler gives lots of examples of how to use it:
Upvotes: 2
Reputation: 328556
Create a new process in Java and write the stream to the stdin of to a tool like SoX to have it convert the audio data to MP3 on the fly.
Upvotes: 0
Reputation: 41132
Lame is indeed the de facto standard on MP3 encoding, partly because of its high quality (encoding MP3 is hard to do right... and it is a subjective art), partly because of legal issues (MP3 is a patented technique, AFAIK, that's why you get Lame binaries from a limited number of sites, most of them in countries where these legal issues are less (or not) enforced).
The LAMEOnJ project found by VonC seems to use a non-free JNI implementation, but I suppose you can do your own binding with JNI or even JNA, particularly if you target a precise system.
Upvotes: 1
Reputation: 3368
As to the first question - is it possible, the only limitation I can see would be processor speed. If the algorithm you are using and your processor are both fast enough, there is no reason why it wouldn't be possible.
I know this isn't Java source, but it may get you on the right track - try looking at the Lame MP3 Encoder.
As far as I know all MP3 conversion algorithms work chunk by chunk. They don't need to read the whole WAV file to begin conversion, but they convert on the fly.
Upvotes: 0