how to convert mp4 to mp3 in java
I'm looking for a minimal way to convert mp4 file to mp3 file programmatically from开发者_如何学JAVA Java. Ideally I also need an cutting of target file.
Do Java libs support this or only 3th party ones? Like jmf, ffmpeg?Thanks!
The most simple way is to use ffmpeg via a ProcessBuilder using this command
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
JAVE it is very simple to convert media file to another format media. http://www.sauronsoftware.it/projects/jave/manual.php
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.
精彩评论