Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where OpenCV does not link with FFMPEG #1732

Closed
wants to merge 2 commits into from

Conversation

furbrain
Copy link

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

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)

@@ -973,6 +973,7 @@ if(AV_BUILD_OPENCV)
CONFIGURE_COMMAND
${CMAKE_COMMAND}
${CMAKE_CORE_BUILD_FLAGS}
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to add a variable
set(FFMPEG_CMAKE_FLAGS -DFFMPEG_ROOT=${CMAKE_INSTALL_PREFIX})
And add it bellow as it's done for the other libs "${TIFF_CMAKE_FLAGS} ${PNG_CMAKE_FLAGS} ${JPEG_CMAKE_FLAGS} ${LIBRAW_CMAKE_FLAGS}"

@fabiencastan
Copy link
Member

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

@furbrain
Copy link
Author

furbrain commented Sep 1, 2024

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

@solonovamax
Copy link

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.

@c-ewing
Copy link
Contributor

c-ewing commented Nov 24, 2024

@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

@furbrain
Copy link
Author

furbrain commented Nov 24, 2024 via email

@c-ewing c-ewing mentioned this pull request Nov 24, 2024
1 task
@fabiencastan
Copy link
Member

#1784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants