Java - Convert ogg to mp3

I am writing a Java program and I would like to convert the ogg file to mp3 file.
I spent a lot of time trying to find a good library to do this, but without success at the moment.

I think I need an ogg decoder (jorbis?) And an mp3 encoder (lameOnJ?).
Moreover, after the conversion is complete, I need to set some tags in the file (Artist / Track tag, etc.).

This application is for Windows and OS X

Could you give me any hint on how to handle, with examples, if possible.

thanks

0
source share
1 answer

You have many options, and it depends on how much effort you want to invest and what limitations you have regarding the execution platform.

Many developers will simply make System.exec () calls to external decoding / encoding / label executable files by writing intermediate files to disk. This is a little awkward, but once it is configured correctly, it works.

A more difficult option is to use libraries like the ones you found. You can still use the file system to temporarily store the uncompressed version.

However, you can avoid the intermediate step β€” and possibly do it faster β€” by pipelining. You must supply the decoder output as an encoder input and set both of them.

The details of this are API dependent. If you're lucky, they can work with pieces, and you can manage them in a single thread.

If they work with threads, you may need to get your hands dirty and work with threads. One stream for the encoder, one for the decoder.

0
source

Source: https://habr.com/ru/post/1439098/


All Articles