Repository navigation
Allow FFmpeg linking on Android - #13726
Conversation
alalek
left a comment
There was a problem hiding this comment.
How did you build FFmpeg for Android? (some instructions which are used)
|
|
||
| # rewrite libraries to absolute paths | ||
| foreach(lib ${FFMPEG_LIBRARIES}) | ||
| find_library(FFMPEG_ABSOLUTE_${lib} "${lib}" PATHS "${FFMPEG_lib${lib}_LIBDIR}" NO_DEFAULT_PATH) |
There was a problem hiding this comment.
Dump values of:
CMAKE_FIND_ROOT_PATH${FFMPEG_lib${lib}_LIBDIR}- your
FFMPEG_INSTALL_PREFIX
There was a problem hiding this comment.
CMAKE_FIND_ROOT_PATH: /home/user/Android/android-ndk-r18b
-- FFMPEG_LIBRARY_DIRS: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libavformat_LIBDIR: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libavcodec_LIBDIR: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libz_LIBDIR:
-- FFMPEG_libswscale_LIBDIR: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libavutil_LIBDIR: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libm_LIBDIR:
-- FFMPEG_libavresample_LIBDIR: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libavutil_LIBDIR: /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/lib
-- FFMPEG_libm_LIBDIR:
FFMPEG_INSTALL_PREFIX /home/user/android-install/ffmpeg-arm64-v8a-n4.0.3
tree of FFMPEG_INSTALL_PREFIX:
/home/user/android-install/ffmpeg-arm64-v8a-n4.0.3/
├── include
│ ├── libavcodec
│ │ ├── ac3_parser.h
│ │ ├── adts_parser.h
│ │ ├── avcodec.h
│ │ ├── avdct.h
│ │ ├── avfft.h
│ │ ├── d3d11va.h
│ │ ├── dirac.h
│ │ ├── dv_profile.h
│ │ ├── dxva2.h
│ │ ├── jni.h
│ │ ├── mediacodec.h
│ │ ├── qsv.h
│ │ ├── vaapi.h
│ │ ├── vdpau.h
│ │ ├── version.h
│ │ ├── videotoolbox.h
│ │ ├── vorbis_parser.h
│ │ └── xvmc.h
│ ├── libavdevice
│ │ ├── avdevice.h
│ │ └── version.h
│ ├── libavfilter
│ │ ├── avfilter.h
│ │ ├── buffersink.h
│ │ ├── buffersrc.h
│ │ └── version.h
│ ├── libavformat
│ │ ├── avformat.h
│ │ ├── avio.h
│ │ └── version.h
│ ├── libavresample
│ │ ├── avresample.h
│ │ └── version.h
│ ├── libavutil
│ │ ├── adler32.h
│ │ ├── aes_ctr.h
│ │ ├── aes.h
│ │ ├── attributes.h
│ │ ├── audio_fifo.h
│ │ ├── avassert.h
│ │ ├── avconfig.h
│ │ ├── avstring.h
│ │ ├── avutil.h
│ │ ├── base64.h
│ │ ├── blowfish.h
│ │ ├── bprint.h
│ │ ├── bswap.h
│ │ ├── buffer.h
│ │ ├── camellia.h
│ │ ├── cast5.h
│ │ ├── channel_layout.h
│ │ ├── common.h
│ │ ├── cpu.h
│ │ ├── crc.h
│ │ ├── des.h
│ │ ├── dict.h
│ │ ├── display.h
│ │ ├── downmix_info.h
│ │ ├── encryption_info.h
│ │ ├── error.h
│ │ ├── eval.h
│ │ ├── ffversion.h
│ │ ├── fifo.h
│ │ ├── file.h
│ │ ├── frame.h
│ │ ├── hash.h
│ │ ├── hmac.h
│ │ ├── hwcontext_cuda.h
│ │ ├── hwcontext_d3d11va.h
│ │ ├── hwcontext_drm.h
│ │ ├── hwcontext_dxva2.h
│ │ ├── hwcontext.h
│ │ ├── hwcontext_mediacodec.h
│ │ ├── hwcontext_qsv.h
│ │ ├── hwcontext_vaapi.h
│ │ ├── hwcontext_vdpau.h
│ │ ├── hwcontext_videotoolbox.h
│ │ ├── imgutils.h
│ │ ├── intfloat.h
│ │ ├── intreadwrite.h
│ │ ├── lfg.h
│ │ ├── log.h
│ │ ├── lzo.h
│ │ ├── macros.h
│ │ ├── mastering_display_metadata.h
│ │ ├── mathematics.h
│ │ ├── md5.h
│ │ ├── mem.h
│ │ ├── motion_vector.h
│ │ ├── murmur3.h
│ │ ├── opt.h
│ │ ├── parseutils.h
│ │ ├── pixdesc.h
│ │ ├── pixelutils.h
│ │ ├── pixfmt.h
│ │ ├── random_seed.h
│ │ ├── rational.h
│ │ ├── rc4.h
│ │ ├── replaygain.h
│ │ ├── ripemd.h
│ │ ├── samplefmt.h
│ │ ├── sha512.h
│ │ ├── sha.h
│ │ ├── spherical.h
│ │ ├── stereo3d.h
│ │ ├── tea.h
│ │ ├── threadmessage.h
│ │ ├── timecode.h
│ │ ├── time.h
│ │ ├── timestamp.h
│ │ ├── tree.h
│ │ ├── twofish.h
│ │ ├── version.h
│ │ └── xtea.h
│ ├── libswresample
│ │ ├── swresample.h
│ │ └── version.h
│ └── libswscale
│ ├── swscale.h
│ └── version.h
├── lib
│ ├── libavcodec.a
│ ├── libavdevice.a
│ ├── libavfilter.a
│ ├── libavformat.a
│ ├── libavresample.a
│ ├── libavutil.a
│ ├── libswresample.a
│ ├── libswscale.a
│ └── pkgconfig
│ ├── libavcodec.pc
│ ├── libavdevice.pc
│ ├── libavfilter.pc
│ ├── libavformat.pc
│ ├── libavresample.pc
│ ├── libavutil.pc
│ ├── libswresample.pc
│ └── libswscale.pc
└── share
└── ffmpeg
└── examples
├── avio_dir_cmd.c
├── avio_reading.c
├── decode_audio.c
├── decode_video.c
├── demuxing_decoding.c
├── encode_audio.c
├── encode_video.c
├── extract_mvs.c
├── filter_audio.c
├── filtering_audio.c
├── filtering_video.c
├── http_multiclient.c
├── hw_decode.c
├── Makefile
├── metadata.c
├── muxing.c
├── qsvdec.c
├── README
├── remuxing.c
├── resampling_audio.c
├── scaling_video.c
├── transcode_aac.c
├── transcoding.c
├── vaapi_encode.c
└── vaapi_transcode.c
14 directories, 154 files
|
Grab Android NDK 18 and create a standalone toolchain (optional, you can comment it in script) checkout ffmpeg git, tags/n4.0.3 OpenCV build: |
|
@nicolaerosia ,could you please check whether the following fix helps in your environment: These |
|
@mshabunin that's not the issue, find_library fails to find the library because So the find path Later Edit: with your change: I added some debug messages to demostrate that find_library invocation is right, and it still doesn't find the libs: With my change: |
|
@nicolaerosia , we use
So, non-rooted directories should be searched too. Could you please provide a list of found/non-found libraries? Can |
|
@mshabunin I always rm -rf my build dir, no worries. It will set Should I update my PR to drop the change in |
|
@nicolaerosia Did you try to add ffmpeg path into CMake's "FIND_ROOT": |
|
@alalek no, I just tried it now and it works |
alalek
left a comment
There was a problem hiding this comment.
Please rebase patch (CMakeLists.txt changes only) onto 3.4 branch. We will merge changes from 3.4 into master regularly (weekly/bi-weekly).
Note: no needs to re-open PR, apply changes "inplace".
| OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON | ||
| VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT | ||
| VISIBLE_IF NOT IOS AND NOT WINRT | ||
| VERIFY HAVE_FFMPEG) |
There was a problem hiding this comment.
ON => NOT ANDROID (disabled by default on Android).
Use WITH_FFMPEG=ON in build scripts.
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" NOT ANDROID
VISIBLE_IF NOT IOS AND NOT WINRT
VERIFY HAVE_FFMPEG)
details: #13726 In order to help CMake and PkgConfig find FFmpeg you need to: 1) export `PKG_CONFIG_LIBDIR=${SYSROOT}` where `SYSROOT=${ANDROID_NDK}/sysroot` 2) Add `-DCMAKE_PREFIX_PATH=${FFMPEG_INSTALL_PREFIX}` 3) Append `-DCMAKE_FIND_ROOT_PATH=${FFMPEG_INSTALL_PREFIX}`
|
@alalek sorry for the delay, I was away for a while |
details: opencv#13726 In order to help CMake and PkgConfig find FFmpeg you need to: 1) export `PKG_CONFIG_LIBDIR=${SYSROOT}` where `SYSROOT=${ANDROID_NDK}/sysroot` 2) Add `-DCMAKE_PREFIX_PATH=${FFMPEG_INSTALL_PREFIX}` 3) Append `-DCMAKE_FIND_ROOT_PATH=${FFMPEG_INSTALL_PREFIX}`
In order to help CMake and PkgConfig find FFmpeg you need to:
PKG_CONFIG_LIBDIR=${SYSROOT}where
SYSROOT=${ANDROID_NDK}/sysroot-DCMAKE_PREFIX_PATH=${FFMPEG_INSTALL_PREFIX}-DCMAKE_FIND_ROOT_PATH=${FFMPEG_INSTALL_PREFIX}Sample scripts are below in comments.
Fixes: #4451 #5236 #12600