Getting Started with FFMPEG-Java

Note : FFMPEG-Java is not the same thing as Jffmpeg. FFMPEG-Java is a sub-project of Freedom for Media in Java, FMJ in short.

This project is licensed under the LGPL. It has optional GPL components for using FFMPEG's GPL swscale library. If you wish to use swscale and the GPL, use ffmpeg-java-gpl.jar. The standard LGPL jar for this project is ffmpeg-java.jar.

FFMPEG-Java is a Java wrapper around FFMPEG, using JNA. It assumes that dynamic libraries for FFMPEG have been compiled, and are in your library path.

Note : mmx is disabled in this example, as it has caused problems in the past.

Step 1 : Get FFMPEG sources from http://ffmpeg.mplayerhq.hu

Step 2 : Build/install FFMPEG

./configure --disable-mmx --enable-shared

make

sudo make install

 

Step 3 : Run one of the sample programs with a media file as the first parameter.

In several *nix systems, sometimes have to set your library path explicitly. For example :

export LD_LIBRARY_PATH=/usr/local/lib

 

PlayerExample

Plays a movie in a window :

java -cp ./ffmpeg-java.jar:./lib/jna.jar net.sf.ffmpeg_java.example.PlayerExample http://www.javasaver.com/testjs/jmf/anim/2005-11-26.mov

 

AVCodecSample

Creates 5 ppm files in the current directory with the first 5 frames of the movie :

java -cp ./ffmpeg-java.jar:./lib/jna.jar net.sf.ffmpeg_java.example.AVCodecSample http://www.javasaver.com/testjs/jmf/anim/2005-11-26.mov

 

Very good documentation how to setup build environment - msys and mingw - and how to build FFMPEG on Windows can be found in here. The FFMPEG builts provided there have worked too, but some image codecs/formats were missing.