java ogg_Java - Convert ogg to mp3

问题

I'm writing a Java program and I'd like to convert a ogg file into mp3 file.

I've spend a lot of time trying to find a good library to do that, but without success for the moment.

I think I'll need a ogg decoder (jorbis ?) and a mp3 encoder (lameOnJ ?).

Moreover, once the conversion is done, I need to set some tags in the file (artist/track tag, etc).

This is a windows and OS X app.

Could you give me any hint about how to process, with examples if possible.

Thanks

回答1:

You have lots of choices, and it depends on how much effort you want to put in, and what constraints you have regarding the execution platform.

Many developers would simply make System.exec() calls to external decode/encode/label executables, writing the intermediate files to disk. This is slightly clunky, but once it's set up properly, it works.

A more sophisticated option is to use libraries such as the ones you've found. You can still use the filesystem to temporarily store the uncompressed version.

You can, however, avoid storing the intermediate step -- and maybe make it faster -- by pipelining. You need to feed the output of the decoder as the input of the encoder, and set them both going.

The details of this depends on the API. If you're lucky, they can work with chunks, and you may be able to manage them in a single thread.

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

来源:https://stackoverflow.com/questions/11883659/java-convert-ogg-to-mp3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值