Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. Ideally I also need an cutting of target file.
Do Java libs support this or only 3th party ones? Like jmf, ffmpeg?

Thanks!

like image 892
yetanothercoder Avatar asked Jun 13 '10 12:06

yetanothercoder


3 Answers

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

like image 153
Paul Gregoire Avatar answered Oct 22 '22 10:10

Paul Gregoire


JAVE it is very simple to convert media file to another format media. http://www.sauronsoftware.it/projects/jave/manual.php

like image 5
David J Avatar answered Oct 22 '22 08:10

David J


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.

like image 2
Curtis Avatar answered Oct 22 '22 09:10

Curtis