AliceVision icon indicating copy to clipboard operation
AliceVision copied to clipboard

Fix bug where OpenCV does not link with FFMPEG

Open furbrain opened this issue 1 year ago • 3 comments

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 avatar Aug 17 '24 19:08 furbrain

@furbrain Will you have time to make the adjustments proposed in the review?

fabiencastan avatar Aug 31 '24 14:08 fabiencastan

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

furbrain avatar Sep 01 '24 13:09 furbrain

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.

solonovamax avatar Sep 07 '24 22:09 solonovamax

@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

c-ewing avatar Nov 24 '24 08:11 c-ewing

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: @.***>

furbrain avatar Nov 24 '24 10:11 furbrain

https://github.com/alicevision/AliceVision/pull/1784

fabiencastan avatar Nov 25 '24 10:11 fabiencastan