AliceVision
AliceVision copied to clipboard
Fix bug where OpenCV does not link with FFMPEG
Description
Currently when building opencv, it does not find ffmpeg, even though it has been built and installed. This means that KeyframeSelector does not run under linux (opencv automatically bundles its own version of ffmpeg under windows).
Features list
- [X] Fix https://github.com/alicevision/Meshroom/issues/2285
Implementation remarks
This PR simply lets the opencv cmake know where to look for various libraries (and fixes a minor bug in getting the base docker image)
@furbrain Will you have time to make the adjustments proposed in the review?
I've tested using the FFMPEG_ROOT option as suggested above - this does not seem to let the opencv cmake find the ffmpeg libraries - possibly because it's actually looking for libav[codec|format|device|etc] libraries etc.
I'm not very good with cmake (python is more my area of expertise) and honestly I've struggled to debug why it doesn't work. I can't see any major harm from telling cmake to look in the general installation prefix for libraries.
Phil
I cannot compile from source as cuda seems to really dislike me for whatever reason.
Would it be possible by any chance for you to pass me a tarball for the meshroom distribution built using this patch?
or even, just a tarball of the alicevision build, as hopefully I should just be able to delete the existing alicevision directory and replace it with this fixed build.
@furbrain Do you mind if i take this over as there hasn't been any progress in a little while? I believe I have a working solution that addresses some of @fabiencastan's concerns.
Basically OpenCV is VERY particular about where packages are installed, especially FFmpeg and it doesn't provide a way of specifying where FFmpeg is located. @fabiencastan's fix will not work as there is no way of specifying (that i have been able to find) the FFmpeg install path. The way around this when compiling OpenCV from source is adding the FFmpeg install location to the prefix path as @furbrain did such that the find_package() used in OpenCV's build also searches in the install prefix defined during the AliceVision build.
Adding the line:
set(FFMPEG_CMAKE_FLAGS -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX};${CMAKE_PREFIX_PATH})
to the FFmpeg build section and then adding {FFMPEG_CMAKE_FLAGS} to the OpenCV section
This would change would the CMAKE_PREFIX_PATH for just OpenCV to include the install path for FFmpeg.
I've tested this using the Docker container and checked the output of /opt/AliceVision_install/bin-deps/opencv_version -v and verified that OpenCV is built against FFmpeg.
Thanks, cewing
This is fine by me!
On Sun, 24 Nov 2024, 08:39 c-ewing, @.***> wrote:
@furbrain https://github.com/furbrain Do you mind if i take this over as there hasn't been any progress in a little while? I believe I have a working solution that addresses some of @fabiencastan https://github.com/fabiencastan's concerns.
Basically OpenCV is VERY particular about where packages are installed, especially FFmpeg and it doesn't provide a way of specifying where FFmpeg is located. @fabiencastan https://github.com/fabiencastan's fix will not work as there is no way of specifying (that i have been able to find) the FFmpeg install path. The way around this when compiling OpenCV from source is adding the FFmpeg install location to the prefix path as @furbrain https://github.com/furbrain did such that the find_package() used in OpenCV's build also searches in the install prefix defined during the AliceVision build.
Adding the line:
set(FFMPEG_CMAKE_FLAGS -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX};${CMAKE_PREFIX_PATH})
to the FFmpeg build section and then adding {FFMPEG_CMAKE_FLAGS} to the OpenCV section
This would change would the CMAKE_PREFIX_PATH for just OpenCV to include the install path for FFmpeg.
I've tested this using the Docker container and checked the output of /opt/AliceVision_install/bin-deps/opencv_version -v and verified that OpenCV is built against FFmpeg.
Thanks, cewing
— Reply to this email directly, view it on GitHub https://github.com/alicevision/AliceVision/pull/1732#issuecomment-2495873585, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAW3PXNNKSVHTIQPILZELQT2CGGEBAVCNFSM6AAAAABMVVMTOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVHA3TGNJYGU . You are receiving this because you were mentioned.Message ID: @.***>
https://github.com/alicevision/AliceVision/pull/1784