bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.69k stars 743 forks source link

Building cpp-presets (ffmpeg) - failing #854

Open nbendix opened 4 years ago

nbendix commented 4 years ago

Hi, I am trying to build javacpp-presets with this command on Mac:

mvn clean install --projects .,ffmpeg -Djavacpp.platform=android-arm -Djavacpp.platform.root=/Android/android-ndk-r18

NDK version is r18

It stops without much info, any idea why?

this is the last many lines of output:

.... The C compiler identification is Clang 7.0.2 -- The CXX compiler identification is Clang 7.0.2 -- Check for working C compiler: /Android/android-ndk-r18/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -- Check for working C compiler: /Android/android-ndk-r18/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Android/android-ndk-r18/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -- Check for working CXX compiler: /Android/android-ndk-r18/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- CMAKE_SYSTEM_PROCESSOR value arm is unknown -- Please add this value near /Users/nikolaib/javacv/javacpp-presets/ffmpeg/cppbuild/android-arm/x265-3.1.2/source/CMakeLists.txt:78 -- Looking for include file inttypes.h -- Looking for include file inttypes.h - found -- Performing Test CC_HAS_NO_STRICT_OVERFLOW -- Performing Test CC_HAS_NO_STRICT_OVERFLOW - Success -- Performing Test CC_HAS_NO_NARROWING -- Performing Test CC_HAS_NO_NARROWING - Success -- Performing Test CC_HAS_NO_ARRAY_BOUNDS -- Performing Test CC_HAS_NO_ARRAY_BOUNDS - Success -- Performing Test CC_HAS_FAST_MATH -- Performing Test CC_HAS_FAST_MATH - Success -- Performing Test CC_HAS_STACK_REALIGN -- Performing Test CC_HAS_STACK_REALIGN - Success -- Performing Test CC_HAS_FNO_EXCEPTIONS_FLAG -- Performing Test CC_HAS_FNO_EXCEPTIONS_FLAG - Success -- Found nasm: /Users/nikolaib/javacv/javacpp-presets/ffmpeg/cppbuild/android-arm/bin/nasm (found version "2.14") -- x265 version 0.0 -- Looking for strtok_r -- Looking for strtok_r - found -- Configuring done -- Generating done -- Build files have been written to: /Users/nikolaib/javacv/javacpp-presets/ffmpeg/cppbuild/android-arm/x265-3.1.2/build/linux/8bit Scanning dependencies of target common Scanning dependencies of target encoder [ 6%] Building CXX object encoder/CMakeFiles/encoder.dir/search.cpp.o [ 6%] Building CXX object encoder/CMakeFiles/encoder.dir/analysis.cpp.o [ 6%] Building CXX object encoder/CMakeFiles/encoder.dir/bitcost.cpp.o [ 8%] Building CXX object common/CMakeFiles/common.dir/primitives.cpp.o [ 10%] Building CXX object common/CMakeFiles/common.dir/pixel.cpp.o [ 12%] Building CXX object encoder/CMakeFiles/encoder.dir/motion.cpp.o [ 14%] Building CXX object common/CMakeFiles/common.dir/dct.cpp.o [ 16%] Building CXX object common/CMakeFiles/common.dir/lowpassdct.cpp.o [ 18%] Building CXX object encoder/CMakeFiles/encoder.dir/slicetype.cpp.o [ 20%] Building CXX object encoder/CMakeFiles/encoder.dir/frameencoder.cpp.o [ 22%] Building CXX object encoder/CMakeFiles/encoder.dir/framefilter.cpp.o [ 24%] Building CXX object common/CMakeFiles/common.dir/ipfilter.cpp.o [ 26%] Building CXX object common/CMakeFiles/common.dir/intrapred.cpp.o [ 28%] Building CXX object encoder/CMakeFiles/encoder.dir/level.cpp.o [ 30%] Building CXX object encoder/CMakeFiles/encoder.dir/nal.cpp.o [ 32%] Building CXX object encoder/CMakeFiles/encoder.dir/sei.cpp.o [ 34%] Building CXX object encoder/CMakeFiles/encoder.dir/sao.cpp.o [ 36%] Building CXX object common/CMakeFiles/common.dir/loopfilter.cpp.o [ 38%] Building CXX object encoder/CMakeFiles/encoder.dir/entropy.cpp.o [ 40%] Building CXX object common/CMakeFiles/common.dir/constants.cpp.o [ 42%] Building CXX object encoder/CMakeFiles/encoder.dir/dpb.cpp.o [ 44%] Building CXX object encoder/CMakeFiles/encoder.dir/ratecontrol.cpp.o [ 46%] Building CXX object common/CMakeFiles/common.dir/cpu.cpp.o [ 48%] Building CXX object common/CMakeFiles/common.dir/version.cpp.o /Users/nikolaib/javacv/javacpp-presets/ffmpeg/cppbuild/android-arm/x265-3.1.2/source/common/cpu.cpp:387:26: warning: unused parameter 'benableavx512' [-Wunused-parameter] uint32_t cpu_detect(bool benableavx512) ^ /Users/nikolaib/javacv/javacpp-presets/ffmpeg/cppbuild/android-arm/x265-3.1.2/source/common/cpu.cpp:61:13: warning: unused variable 'enable512' [-Wunused-variable] static bool enable512 = false; ^ 2 warnings generated. [ 51%] Building CXX object common/CMakeFiles/common.dir/threading.cpp.o [ 53%] Building CXX object encoder/CMakeFiles/encoder.dir/reference.cpp.o [ 55%] Building CXX object encoder/CMakeFiles/encoder.dir/encoder.cpp.o [ 57%] Building CXX object common/CMakeFiles/common.dir/threadpool.cpp.o [ 59%] Building CXX object encoder/CMakeFiles/encoder.dir/api.cpp.o [ 61%] Building CXX object common/CMakeFiles/common.dir/wavefront.cpp.o [ 63%] Building CXX object common/CMakeFiles/common.dir/md5.cpp.o [ 65%] Building CXX object encoder/CMakeFiles/encoder.dir/weightPrediction.cpp.o [ 67%] Building CXX object common/CMakeFiles/common.dir/bitstream.cpp.o [ 69%] Building CXX object common/CMakeFiles/common.dir/yuv.cpp.o [ 71%] Building CXX object common/CMakeFiles/common.dir/shortyuv.cpp.o [ 73%] Building CXX object common/CMakeFiles/common.dir/picyuv.cpp.o [ 75%] Building CXX object common/CMakeFiles/common.dir/common.cpp.o [ 77%] Building CXX object common/CMakeFiles/common.dir/param.cpp.o [ 79%] Building CXX object common/CMakeFiles/common.dir/frame.cpp.o [ 79%] Built target encoder [ 81%] Building CXX object common/CMakeFiles/common.dir/framedata.cpp.o [ 83%] Building CXX object common/CMakeFiles/common.dir/cudata.cpp.o [ 85%] Building CXX object common/CMakeFiles/common.dir/slice.cpp.o [ 87%] Building CXX object common/CMakeFiles/common.dir/lowres.cpp.o [ 89%] Building CXX object common/CMakeFiles/common.dir/piclist.cpp.o [ 91%] Building CXX object common/CMakeFiles/common.dir/predict.cpp.o [ 93%] Building CXX object common/CMakeFiles/common.dir/scalinglist.cpp.o [ 95%] Building CXX object common/CMakeFiles/common.dir/quant.cpp.o [ 97%] Building CXX object common/CMakeFiles/common.dir/deblock.cpp.o [ 97%] Built target common Scanning dependencies of target x265-static [100%] Linking CXX static library libx265.a warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: warning for library: libx265.a the table of contents is empty (no object file members in the library define global symbols) [100%] Built target x265-static usage: ar -d [-TLsv] archive file ... ar -m [-TLsv] archive file ... ar -m [-abiTLsv] position archive file ... ar -p [-TLsv] archive [file ...] ar -q [-cTLsv] archive file ... ar -r [-cuTLsv] archive file ... ar -r [-abciuTLsv] position archive file ... ar -t [-TLsv] archive [file ...] ar -x [-ouTLsv] archive [file ...] [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] JavaCPP Presets 1.5.3-SNAPSHOT ..................... SUCCESS [ 2.045 s] [INFO] JavaCPP Presets for FFmpeg 4.2.2-1.5.3-SNAPSHOT .... FAILURE [11:26 min] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 11:30 min [INFO] Finished at: 2020-03-23T20:41:37+01:00

saudet commented 4 years ago

It seems like the build for x265 is looking for GNU versions of ar, ranlib, etc. They are available in the tree of the NDK, so it's possible to set something somewhere for this... It works fine if we run the build from Linux though: https://github.com/bytedeco/javacpp-presets/wiki/Build-Environments#android-arm-arm64-x86-and-x86_64

nbendix commented 4 years ago

ok. Thanks for quick reply.

I switched to compiling on Ubuntu.

Things work better now.

I get this error: JacaCPP Builder: Could not parse "libpostproc/postprocess.h": File does not exist, any idea how to fix it?

I noticed some of the .so files where being compiled (not the jni's), so i tried using those, but getting some errors. do i need the jni's for the new .so files to work?

nbendix commented 4 years ago

i tried enabling postproc. but same issue.

this is my ffmpeg settings:

DISABLE="--disable-iconv --disable-libxcb --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-everything"

ENABLE="--enable-shared --enable-runtime-cpudetect --enable-libopenh264 --enable-encoder=libopenh264 --enable-encoder=aac --enable-encoder=mjpeg --enable-decoder=h264 --enable-decoder=aac --enable-decoder=mjpeg --enable-parser=h264 --enable-parser=aac --enable-parser=mjpeg --enable-muxer=mp4 --enable-muxer=rtsp --enable-muxer=mjpeg --enable-demuxer=mov --enable-demuxer=rtsp --enable-demuxer=mjpeg --enable-protocol=file --enable-protocol=http --enable-protocol=rtp --enable-protocol=rtmp --enable-postproc"

saudet commented 4 years ago

You'll need to enable GPL to get postproc. If you don't need it, simply remove it, that's fine.

nbendix commented 4 years ago

super. i have it compiling now. thx.

with my new limited version i get an exception when starting ffmpegFrameFilter: avfilter_graph_create_filter() error -12: Cannot create setpts filter.

For debug purpose i tested with an empty filter. still same exception.

We are not directly using the setpts filter. So is there a way i can disable that in framefilter?

or do you know what to include in build to make it work?

nbendix commented 4 years ago

this is my updated build settings:

minimal configuration to support MPEG-4 streams with H.264 and AAC as well as Motion JPEG

DISABLE="--disable-iconv --disable-libxcb --disable-opencl --disable-sdl2 --disable-bzlib --disable-lzma --disable-linux-perf --disable-everything"

ENABLE="--enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --enable-libopenh264 --enable-encoder=libopenh264 --enable-encoder=aac --enable-encoder=mjpeg --enable-decoder=h264 --enable-decoder=aac --enable-decoder=mjpeg --enable-parser=h264 --enable-parser=aac --enable-parser=mjpeg --enable-muxer=mp4 --enable-muxer=rtsp --enable-muxer=mjpeg --enable-demuxer=mov --enable-demuxer=rtsp --enable-demuxer=mjpeg --enable-protocol=file --enable-protocol=http --enable-protocol=rtp --enable-protocol=rtmp"

saudet commented 4 years ago

setpts is a pretty basic filter. If you didn't include that one in the build, there is little chance that any other filter will work. In any case, just include it in the build, there's no reason to leave it out.

nbendix commented 4 years ago

thanks. --enable-filters got it working.

It seems we have a working version now.

I think we can remove more, but will paste my settings when we have done some more setting. maybe it can be used by others.

pgfsim commented 4 years ago

I'm having the exact same issue as OP trying to build ffmpeg for android-arm64 on Mac. After x265 EOF it just stops and doesn't continue to build the ffmpeg library.

[100%] Linking CXX static library libx265.a
warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: warning for library: libx265.a the table of contents is empty (no object file members in the library define global symbols)
[100%] Built target x265-static
Admins-MacBook-Pro:javacpp-presets-platform-1.5.3 Admin$

Looking at the multilib.sh file in the x265 source it actually uses this for Mac:

mv libx265.a libx265_main.a

libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null

I still can't get it to continue the build script though even with the above edit

pgfsim commented 4 years ago

Ok so the reason it was exiting with no error is the set -eu in the parent cppbuild.sh. It now continues to build ffmpeg although I do get libx265 not found test.c:(.text.check_x265_encoder_encode+0x0): undefined reference to x265_encoder_encode. I think this is a separate issue.