Introduction

FFSampledSP is a free implementation of the javax.sound.sampled.spi interfaces. It is part of the SampledSP collection of javax.sound.sampled libraries.

Its main purpose is to decode audio from various formats at high speed using FFmpeg 2.3.3. To do so, it uses the tagtraum FFmpeg package, which offers FFmpeg binaries configured to decode audio while avoiding codecs with patent problems. In other words, it supports formats like OGG and FLAC well, while leaving MPEG-4 and MP3 unsupported. In order to decode those, please see alternatives below.

Because FFSampledSP depends on native code, you need to add the provided jnilib/dll to your java.library.path (make sure it's named ffsampledsp.dll or libffsampledsp.jnilib) and the provided jar to your classpath. Everything else is taken care of automatically.

Getting Started

The easiest way to use FFSampledSP (other than simply using the jar and jnilib/ 64bit-dll/ 32bit-dll) is to start a Maven project and introduce a FFSampledSP dependency.

To do so, add something like this to the dependencies section of your pom:

<dependency>
    <groupId>com.tagtraum</groupId>
    <artifactId>ffsampledsp-java</artifactId>
    <version>0.9.7</version>
    <type>jar</type>
</dependency>

<dependency>
    <groupId>com.tagtraum</groupId>
    <!-- artifact for the OS X universal fat binary -->
    <artifactId>ffsampledsp-universal</artifactId>
    <version>0.9.7</version>
    <type>jnilib</type>
</dependency>

<!-- alternative dependency for 64bit Windows -->
<!--
<dependency>
    <groupId>com.tagtraum</groupId>
    <artifactId>ffsampledsp-x86_64-mingw</artifactId>
    <version>0.9.7</version>
    <type>dll</type>
</dependency>
-->

<!-- alternative dependency for 32bit Windows -->
<!--
<dependency>
    <groupId>com.tagtraum</groupId>
    <artifactId>ffsampledsp-i386-mingw</artifactId>
    <version>0.9.7</version>
    <type>dll</type>
</dependency>
-->

<!-- alternative dependency for 64bit OS X -->
<!--
<dependency>
    <groupId>com.tagtraum</groupId>
    <artifactId>ffsampledsp-x86_64-darwin</artifactId>
    <version>0.9.7</version>
    <type>jnilib</type>
</dependency>
-->

<!-- alternative dependency for 32bit OS X -->
<!--
<dependency>
    <groupId>com.tagtraum</groupId>
    <artifactId>ffsampledsp-i386-darwin</artifactId>
    <version>0.9.7</version>
    <type>jnilib</type>
</dependency>
-->

If Maven can't resolve a dependency, you might also want to add the following repository to the repositories section of your pom:

<repository>
    <id>beatunes</id>
    <name>beaTunes Repository</name>
    <url>http://www.beatunes.com/repo/maven2</url>
</repository>

To use the library, simply use the javax.sound.sampled classes like you normally would.

Requirements

On OS X, FFSampledSP requires OS X 10.6 or later and an Intel processor. Both 32 bit and 64 bit are supported. On Windows, FFSampledSP should run with Windows XP or higher. Both 32 bit and 64 bit are supported.

Alternatives

For a cross platform (OS X/Windows) 32 bit service provider based on QuickTime, check out QTSampledSP.

For a 32/64 bit service provider implementation for Windows 7 or later, based on Microsoft's Media Foundation, check out MFSampledSP. This provider also supports a number of MPEG-4 formats (MP4, M4A, MOV, etc.) as well as MP3.

For a service provider based on Apple's CoreAudio, check out CASampledSP. This provider also supports many codecs with patent problems.

Other Java FFmpeg Projects

There are numerous other Java-FFmpeg projects. Here's the short list, of the projects I'm aware of:

  • Xuggle - Java wrapper around FFmpeg using JNI.
  • jjmpeg - thin Java wrapper around FFmpeg using JNI.
  • JAVE - Java wrapper around FFmpeg executables.
  • FFMPEG-Java - Java wrapper around FFmpeg, using JNA. Apparently abandoned in 2007.
  • Jffmpeg - Plugins for the Java Media Framework (JMF). Apparently abandoned in 2006.

As far as I am aware, except for the abandoned Jffmpeg, all these wrappers require you to learn either the FFmpeg API or some other proprietary API. Contrary to this, you can use the familiar Java APIs when using FFSampledSP or other SampledSP libraries for decoding audio.

FFmpeg Sources

You can find the FFmpeg sources used for this package here.