How to build opencv with latest version of Gstreamer 1.18

what i am trying to achieve is to use latest version Gstreamer with opencv in Ubuntu 18.04
Looking forward to hear.


and what’s the issue?

need to build gstreamer, the version in the cmake stays 1.14 even i have manually changed the path to .so files of gstreamer
Error : Make Error in modules/videoio/CMakeLists.txt:
Imported target “ocv.3rdparty.gstreamer” includes non-existent path


in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:

  • The path was deleted, renamed, or moved to another location.

  • An install or uninstall procedure did not complete successfully.

  • The installation package was faulty and references files it does not

clear the build directory, or at least CMakeCache.txt

i tried that , then it’s not detecting gstreamer at all

have you successfully built gstreamer, or installed a package of gstreamer that contains development files (libraries, headers)?

/usr/bin/ld: /usr/local/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9’ can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:461: recipe for target ‘lib/’ failed
make[2]: *** [lib/] Error 1
CMakeFiles/Makefile2:2392: recipe for target ‘modules/videoio/CMakeFiles/opencv_videoio.dir/all’ failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…

that isn’t gstreamer, that’s ffmpeg

you need to build ffmpeg differently. see here, same error that says “recompile with -fPIC”, and same resolution: Error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’ - #8 by crackwitz

What i noticed is the gstreamer is not able to build with libav , is this also an issue due to ffmpeg?

libav* (libavformat, libavcodec, …) are the libraries of ffmpeg. “ffmpeg”, in the context of OpenCV, means “ffmpeg libraries”.

gstreamer does not depend on ffmpeg.
ffmpeg does not depend on gstreamer.

OpenCV can use either or both.

you did not show issues with building gstreamer itself. you don’t need to build gstreamer.

you showed issues with building OpenCV, where ffmpeg and/or gstreamer were the issue.

you need to provide specific information, i.e. precisely what you do, and all log outputs.

Apologies for the confusion. I am totally new to this.
When i did the Gstreamer installation , i got a similar error regarding libgstav.
So i disabled that certain sub-project and installed it.

After that i tried install OpenCV with that Gstreamer support.
At that time i got the error i mentioned above.
So i thought that was due to the disabled module.

As you shared above link which confirmed it’s an issue related to FFmpeg which i didn’t needed, so i removed it in cmake.list and builded OpenCV.
And that helped me .
Let me know if anything need to be clarified.
Thanks again.