java 如何在java中将mp4转换为mp3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/3032280/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to convert mp4 to mp3 in java
提问by yetanothercoder
I'm looking for a minimal way to convert mp4 file to mp3 file programmatically from Java. Ideally I also need an cutting of target file.
Do Java libs support this or only 3th party ones? Like jmf, ffmpeg?
我正在寻找一种以编程方式从 Java 将 mp4 文件转换为 mp3 文件的最小方法。理想情况下,我还需要切割目标文件。
Java 库支持这个还是只支持第 3 方的库?像jmf,ffmpeg?
Thanks!
谢谢!
回答by Paul Gregtheitroade
The most simple way is to use ffmpeg via a ProcessBuilder using this command
最简单的方法是使用此命令通过 ProcessBuilder 使用 ffmpeg
ffmpeg -i input.mp4 -vn -s 00:00:10 -acodec libmp3lame output.mp3
This translates to: read mp4 file, ignore video, output 10 seconds in mp3 format
这转化为:读取 mp4 文件,忽略视频,以 mp3 格式输出 10 秒
回答by David J
JAVE it is very simple to convert media file to another format media. http://www.sauronsoftware.it/projects/jave/manual.php
JAVE 将媒体文件转换为另一种格式的媒体非常简单。http://www.sauronsoftware.it/projects/jave/manual.php
回答by Curtis
I assume you're going to strip out the audio from your mp4 file and save it as mp3. I haven't tried to do anything with audio encodings, but I've used Xuggler ( http://www.xuggle.com/xuggler/) pretty successfully as a library to access video, and their documentation claims to support audio as well.
我假设您要从 mp4 文件中删除音频并将其另存为 mp3。我没有尝试对音频编码做任何事情,但我已经非常成功地使用 Xuggler ( http://www.xuggle.com/xuggler/) 作为访问视频的库,并且他们的文档声称也支持音频.

