use java-ffmpeg wrapper, or simply use java runtime to execute ffmpeg?

There are a lot of Java libraries providing FFMPEG wrappers. However, most of these libraries are unfortunately outdated and use old FFMPEG versions which lack some important codecs (e.g. Xuggler, humble video, JavaAV, JavaAVC, and jave). So be careful when using those projects!

However, there is one FFMPEG wrapper that is still actively developed and supports FFMPEG 4:

  • JavaCPP FFMPEG - with fully bundled maven artefacts

Alternatively you can use a wrapper for the command line interface of FFMPEG, such as ffmpeg-cli-wrapper. Then it's in your hand to update ffmpeg manually without having to wait for a new release of the wrapper library.


If I'm not mistaken, the "ffmpeg-wrapper" project you linked to is out of date and not maintained. FFmpeg is a very active project, lot's of changes and releases all the time.

You should look at the Xuggler project, this provides a Java API for what you want to do, and they have tight integration with FFmpeg.

http://www.xuggle.com/xuggler/

Should you choose to go down the Runtime.exec() path, this Red5 thread should be useful:

http://www.nabble.com/java-call-ffmpeg-ts15886850.html


I too am looking for something to wrap FFMPEG in Java. While searching, I found this: https://github.com/bramp/ffmpeg-cli-wrapper.

As of today, it seems to have been modified a month ago. So, hopefully it will stick around for a while.

A sample from their docs:

FFmpeg ffmpeg = new FFmpeg("/path/to/ffmpeg");
FFprobe ffprobe = new FFprobe("/path/to/ffprobe");

FFmpegBuilder builder = new FFmpegBuilder()
    .setInput(in)
    .overrideOutputFiles(true)
    .addOutput("output.mp4")
        .setFormat("mp4")
        .setTargetSize(250000)

        .disableSubtitle()

        .setAudioChannels(1)
        .setAudioCodec("libfdk_aac")
        .setAudioRate(48000)
        .setAudioBitrate(32768)

        .setVideoCodec("libx264")
        .setVideoFramerate(Fraction.getFraction(24, 1))
        .setVideoResolution(640, 480)

        .setStrict(FFmpegBuilder.Strict.EXPERIMENTAL)
        .done();

FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
executor.createTwoPassJob(builder).run();