bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.68k stars 744 forks source link

Can't manage to add libfdk_aac to ffmpeg presets #211

Open fppont opened 8 years ago

fppont commented 8 years ago

Hello,

We're trying to recompile ffmpeg project with the --enable-libfdk-aac, 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- Added 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

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

fppont commented 8 years ago

Quick update: we finally managed to make it work (at least on MacosX) with the above config - still having some troubles recompiling the whole project for linux. Will post the full solution and walkthrough once it works on linux.

saudet commented 8 years ago

Please use Docker for Linux builds: https://github.com/bytedeco/javacpp-presets/wiki/Build-Environments#linux-x86-and-x86_64

saudet commented 8 years ago

Thanks in advance for the contribution!

fppont commented 8 years ago

No worries :) In the end there were not any issue with the javacpp presets for ffmpeg. The way we added libfdk in the preset (as I described it in my very first 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.

We can close this issue, but that could be interesting to commit this method (and the related amends) to the javacv project.

saudet commented 8 years ago

Yes of course it would be good to add the modifications. Please send pull requests when you're done with them! Thanks