Java-将ogg转换为mp3 [英] Java - Convert ogg to mp3

查看:400
本文介绍了Java-将ogg转换为mp3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Java程序,我想将ogg文件转换为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.

我想我需要一个ogg解码器(jorbis?)和一个mp3编码器(lameOnJ?). 此外,转换完成后,我需要在文件中设置一些标签(艺术家/曲目标签等).

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).

这是Windows和OS X应用程序.
您能否给我任何有关如何处理的提示,并在可能的情况下提供示例.

This is a windows and OS X app.
Could you give me any hint about how to process, with examples if possible.

谢谢

推荐答案

您有很多选择,这取决于您要付出多少努力以及对执行平台有哪些限制.

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.

许多开发人员只需对外部解码/编码/标签可执行文件进行System.exec()调用,即可将中间文件写入磁盘.这有点笨拙,但是一旦正确设置,它就可以工作.

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.

此操作的详细信息取决于API.如果幸运的话,它们可以使用块,并且您可以在单个线程中对其进行管理.

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.

这篇关于Java-将ogg转换为mp3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆