有没有纯java方法将.wav转换为.mp3?
我在 Java 方面遇到了很多困难,但无法将 Java .wav 到 .mp3 转换器的工作示例结合起来。该转换器将在 Java 小程序中使用,因此它应该仅依赖于用纯 Java 编写的库,而不需要底层 C 代码调用。
任何人都可以提供一个完整的工作示例吗?
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
阅读您的波形文件@ http://java.sun.com/javase/技术/桌面/媒体/jmf/
并编码为 mp3 @ http://openinnowhere.sourceforge.net/lameonj/
如所指出的, lameonj 不是一个纯 java 解决方案。为此,选项似乎没有那么多,但请参阅另一个SO问题:MP3 Encoding in Java
Read your wave file @ http://java.sun.com/javase/technologies/desktop/media/jmf/
and encode to mp3 @ http://openinnowhere.sourceforge.net/lameonj/
As pointed out, lameonj is not a pure java solution. For that the options don't seem so many, but see the other SO question: MP3 Encoding in Java
我在项目中使用Jump3r将wav转换为mp3,因为IE11的html5播放器无法播放wav文件。
Jump3r 是在 tomcat servlet 内运行的最简单的解决方案。由于安全管理器的原因,我无法集成其他解决方案,例如 jave...Jump3r 是一个纯 java 程序。
Jump3r 可在 Maven 存储库中使用 (https://mvnrepository.com/artifact/de .sciss/jump3r/1.0.4),源代码可在 github 上找到(https://github.com/sciss/jump3r/1.0.4)。 com/Sciss/jump3r)
要转换文件,您应该调用 main 方法(在下面的代码中,我使用 main 方法的内联版本来捕获/抛出 IOException(如果需要))
I use Jump3r to convert wav to mp3 on my project because the html5 player of IE11 can't play wav files.
Jump3r is the simpliest solution found to run inside a tomcat servlet. I wasn't able to integrate others solutions like jave certainly due to the security manager... Jump3r is a pure java program.
Jump3r is available on the maven repository (https://mvnrepository.com/artifact/de.sciss/jump3r/1.0.4) and the sources are available on github (https://github.com/Sciss/jump3r)
To convert a file, you should call the main method (in the following code, I use an inlined version of the main method to catch/throw an IOException if necessary)
如果速度对您来说并不重要,请采用 MP3 的任何 c 实现(例如 lame)并尝试使用 NestedVM 到 Java 字节码。它会很慢(就像模拟器中的模拟器一样),但它应该可以工作。
而且它比尝试将 MP3 库移植到纯 Java 的工作量应该要少得多。
If speed is not important for you, take any c implementation of MP3 (e. g. lame) and try to compile it with NestedVM to Java bytecode. It will be slow (like an emulator in an emulator), but it should work.
And it should be way less work than trying to port a MP3 library to pure Java.
请参阅 SourceForge 上的此链接http://sourceforge.net/projects/jump3r/files/
JAR 是唯一的(没有源代码),但它确实可以在 PC 和 Android 上运行,但不一定如作者发布的描述 http://pure-java-mp3-encoder.blogspot.com.au/
我通过使用 Jump3r-1.0.3.jar 文件作为库让它工作,并实例化
然后使用 mp3.Main 调用 mp3.run()
例如,我的 Android 代码的一部分
我怀疑可以直接调用传递数据缓冲区等的 lame 编码器,但由于这个 Java 版本的确切 API 没有记录,所以需要一些研究
See this link on SourceForge http://sourceforge.net/projects/jump3r/files/
Its JAR's only (no source code), but it does work on both PC and Android, but no necessarily as described in the authors posting http://pure-java-mp3-encoder.blogspot.com.au/
I got it to work by just using the jump3r-1.0.3.jar file, as a library, and instantiated
mp3.Main then used called mp3.run()
e.g. part of my Android code
I suspect it would be possible to directly call the lame encoder passing buffers of data etc, but as the exact API for this Java version is not documented, it would require some research
另一个可能相关的项目是 jffmpeg。这显然是为了让 JMF 支持使用本机和 Java 编解码器的多种格式。从“格式”页面来看,他们在纯 Java 方面取得了重大进展。不幸的是,该项目已经沉寂了。
这在短期内不会直接帮助OP。但如果他或其他人热衷于长期拥有纯 Java 编解码器,请考虑参与其中。
Another potentially relevant project is jffmpeg. This apparently aimed to an JMF support for a wide range of formats using both native and Java codecs. Judging from the 'formats' page, they made significant progress on the pure Java side. Unfortunately, the project has gone quiet.
This doesn't directly help the OP in the short term. But if he or others are keen to have pure Java codecs in the long term, consider getting involved.
只需查看以下源代码即可。
http://jsidplay2.cvs.sourceforge.net/jsidplay2/jump3r
它仍在进行中,但是是基于纯 java 的 lame 库的编码器部分的工作示例。
Just check out the following source code.
http://jsidplay2.cvs.sourceforge.net/jsidplay2/jump3r
It is still work in progress, but a working example of the encoder part of a pure java based lame library.