Search code examples
javamavenffmpegjavacvjavacpp

Javacpp: Can't manage to add libfdk_aac to ffmpeg presets


We're trying to recompile ffmpeg project using javacpp and with the --enable-libfdk-aac enabled, the build works, but we can't use libfdk_aac to decode an audio_stream.

We are calling : avcodec_find_decoder_by_name("libfdk_aac") and getting the following result:

Exception: avcodec_find_decoder() error: Unsupported audio format or codec not found: 86018.

We've modified the ccpbuild.sh in the ffmpeg directory in the following way:

  1. Adding the instruction: --enable-libfdk-aac in the ENABLE variable

  2. Getting the dependency : download https://github.com/mstorsjo/fdk-aac/tarball/master fdk-aac.tar.gz

  3. Unpacking it: tar -xzvf ../fdk-aac.tar.gz

  4. Installing it: cd ../mstorsjo-fdk-aac* autoreconf -fiv ./configure --prefix=$INSTALL_PATH --disable-shared --with-pic make -j $MAKEJ make install

I'm running all this on a macosx platform.

The process seems to be ok, and I can compile the project properly with maven, but then it does not work when I'm calling the codec "libfdk_aac". I was wondering if I'm doing something wrong, or is there any other place where I need to register this codec ? (especially since this is an external library)

Many Thanks


Solution

  • In the end there are not any issue with the javacpp presets for ffmpeg. The way we added libfdk in the preset (as I described it in my question post), was correct.

    However in the FFmpegFrameGrabber class in Javacv, we were missing a method to "force" an audio codec when decoding the media. We've modified this class to add a setAudioCodecName method and this is now working properly. We can then set libfdk_aac (or any other codec) to decode audio, or encode audio with it using the FFmpegFrameRecorder.