# Build OpenCV with GStreamer & Contrib Modules [2025]

> The goal of this tutorial is a simple step-by-step compilation of Opencv 4.2 with the contribution of extra modules with GStreamer as a bonus.

- Canonical URL: https://www.funvisiontutorials.com/blog/build-opencv-gstreamer-contrib-modules-2025/
- Author: Vladimir Kucera
- Published: 2020-03-16
- Updated: 2026-02-20
- Topics: Installing & building OpenCV, GStreamer
- Videos: https://www.youtube.com/watch?v=xQIlZjXIZ_s, https://www.youtube.com/watch?v=F8oBROZXoA0

The goal of this tutorial is a simple step-by-step compilation of Opencv 4.2 with the contribution of extra modules with GStreamer as a bonus. The environment is Windows 10, Visual Studio 2019 C++ application. This took me almost one day to correct of CMake setting. The goal of this tutorial is: to compile a set of OpenCV libraries with GStreamer and FFmpeg on Windows. I focus mainly on GStreamer. It is a little bit more tricky. You will find the following information about your Opencv environment by compiling and running this simple code. The Opencv GStreamer is turned as YES. GStreamer gives you a great opportunity to stream OpenCV output video outside of your program, for example, a web application.

I recently compiled with OpenCV 4.4. The update at the end of the post.

**It is working!! wow, The working app and configuration in future tutorials.**

[Image: opencv on web video stream]

```cpp
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
int main()
{
    std::cout << "Hello World!\n";
    std::cout << cv::getBuildInformation() << std::endl;
    std::getchar();
}
```

[Image: Visual studio opencv gstreamer]

## Environment for opencv under Windows compiled with extra modules and GStreamer

**1)** Get Opencv source. I would like to recommend taking the released version. I took the Opencv 4.2 source code zip on the left and released opencv\_contrib 4.2 zip on the right.

[https://github.com/opencv/opencv\_contrib/releases](https://github.com/opencv/opencv_contrib/releases)

[https://github.com/opencv/opencv/releases](https://github.com/opencv/opencv/releases)

[Image: GitHub release pages for OpenCV 4.2.0 and opencv\_contrib, showing the source archives and downloadable assets]

**2)** Get Cmake, I will recommend downloading the 3.17 release candidate 3 for 64-bit Windows. I failed with 3.16.5.

**3)** Extract OpenCV source into opencv-4.2.0

**4)** Extract OpenCV source into opencv\_contrib-4.2.0

**5)** Extract Cmake for example into the same root folder [https://cmake.org/download/](https://cmake.org/download/)

[Image: CMake download page with the Windows win64-x64 ZIP of release candidate 3.17.0-rc3 circled in red]

**6)** Create the empty build folder as you can see on the image with directories.

[Image: Windows folder listing with build, cmake-3.17.0-rc3-win64-x64, opencv\_contrib-4.2.0 and opencv-4.2.0 extracted side by side]

**7)** Download and install GStreamer from [https://gstreamer.freedesktop.org/download/](https://gstreamer.freedesktop.org/download/)

MSVC 64-bit (VS 2019), You can download and install both, but the[1.16.2 development installer](https://gstreamer.freedesktop.org/data/pkg/windows/1.16.2/gstreamer-1.0-devel-msvc-x86_64-1.16.2.msi) for MSVC 64-bit (VS 2019) is important.

-   [1.16.2 runtime installer](https://gstreamer.freedesktop.org/data/pkg/windows/1.16.2/gstreamer-1.0-msvc-x86_64-1.16.2.msi)
-   [1.16.2 development installer](https://gstreamer.freedesktop.org/data/pkg/windows/1.16.2/gstreamer-1.0-devel-msvc-x86_64-1.16.2.msi)[Image: GStreamer Windows download page with the MSVC 64-bit (VS 2019) runtime and development installers circled in red]

The result of the installation is this directory structure.  It will be linked with our Cmake configuration later on.

[Image: The installed GStreamer folder at C:/gstreamer/1.0/x86\_64, containing bin, etc, include, lib, libexec and share]

**8)** Make sure you have Visual Studio 2019 with all C++ functionality

## Configure Cmake to compile Opencv with GStreamer on Windows

I have a problem with this for a long time. I installed OpenCV with FFmpeg and GStreamer on Linux Debian and on Ubuntu many times. I installed OpenCV with contribution and FFmpeg libraries on Windows as well many times. The Opencv GStreamer took me almost a whole weekend to let this work. It is not so difficult at all.

**9)**  Open cmake/bin folder and start cmake-gui.exe

**10)**Add "where is the source code" as main _/opencv-4.2.0_ folder

**11)**Add "where to build the binaries" as new created _/build_ folder

[Image: CMake GUI with the OpenCV source folder and the empty build folder filled in, arrows pointing from the Explorer window, before pressing Configure]

**12)** Hit configure button and select Visual Studio 2019

[Image: CMake generator dialog with Visual Studio 16 2019 selected and Use default native compilers checked]

**13)** Wait for the end of configuration and ADD OENCV\_EXTRA\_MODULES\_PATH

to point into /opencv\_contrib-master/modules

[Image: OPENCV\_EXTRA\_MODULES\_PATH highlighted in the CMake variable list, pointing at the opencv\_contrib-master modules folder]

**14)** **Lesson learned** Correct the path of extra modules with this **/**

**If you use path c:**\\opencv\_contrib-master**\\**modules the error message when parsing string problem will occur.

[Image: CMake reporting a 'when parsing string' error because OPENCV\_EXTRA\_MODULES\_PATH was entered with backslashes instead of forward slashes]

**15)** Set all GStreamer paths as follows:

**Note:** Some points directly to xx.lib which is important!! Some points in the header include the directory.

[Image: CMake variables filtered by 'gst', showing every GSTREAMER library and include path resolved under C:/gstreamer/1.0/x86\_64 and WITH\_GSTREAMER ticked]

[Image: CMake output with GStreamer YES (1.16.2) circled under Video I/O, next to a File Explorer window showing the GStreamer lib folder]

**16)** Hit Configure
**17)** Hit Generate if the configuration is OK
**18)** Open project if 16- 17 are DONE

[Image: CMake finishing with Configuring done and Generating done, and the Configure, Generate and Open Project buttons marked 16, 17 and 18]

## Build a Visual Studio Opencv project with GStreamer on Windows

**19)** Change project to Release and x64

[Image: The generated OpenCV solution open in Visual Studio 2019, with Release and x64 circled in the toolbar]

**20)** Right-click on whole **solution and select build solution**

**[Image: Visual Studio build output ending in Build: 153 succeeded, 0 failed after building the whole OpenCV solution]**

**21)** After the solution is successfully built, **install the solution by build just INSTALL in the solution**

[Image: The INSTALL target selected under CMakeTargets in Visual Studio's Solution Explorer]

[Image: Visual Studio installing OpenCV headers, DLLs and the haarcascade and lbpcascade XML files into build3/install]

**22)** installation is done, The ready to use libraries and headers are located under **build/install**
[Image: The finished build/install folder containing bin, etc, include and x64]

## Visual Studio 2019 Opencv with GStreamer configuration

**24)** Create a new C++ console application in Visual Studio 2019

**25)** Change the project to x64, I am using Release configuration.

**26)** Open property of your project and set Additional include directory. This variable points into the include directory under install folder. (picture above)

[Image: Visual Studio project properties with the OpenCV install/include folder added to Additional Include Directories]

**27)** Under Linker- General- Additional Library Directories set- path to your install lib directory example c:\\xxx\\xxx\\build3\\install\\x64\\vc16\\lib
[Image: Visual Studio linker settings with install/x64/vc16/lib added to Additional Library Directories]
**28)** Under Linker-Input -Set Additional dependencies variable- Set names of OpenCV libraries as opencv\_core420.lib
[Image: opencv\_core420.lib typed into the linker's Additional Dependencies field]
**29)** Copy opencv\_core420.dll into your project next to testOpencvGstreamer.exe or set environment variables to find your OpenCV dlls.
**30)** Compile the project and with the expected result
[Image: The finished test program printing cv::getBuildInformation(), with GStreamer YES (1.16.2) listed under Video I/O]

The next tutorial will be about the OpenCV GStreamer program example.

### UPDATE OPENCV GStreamer

To use GStreamer you need to add path system environment variables to access GStreamer runtime as follows.

[Image: gstreamer windows 10 opencv]

## Opencv GStreamer YouTube tutorial for Visual Studio

### YouTube tutorial build OpenCV from source with Gstreamer on Windows

###

Video: https://www.youtube.com/watch?v=xQIlZjXIZ_s

### This will be a future tutorial on how to build the Opencv Gstreamer app on Windows.

Video: https://www.youtube.com/watch?v=F8oBROZXoA0

### Thanks for sharing: How to compile OpenCV  with GStreamer on Windows Visual Studio

### Opencv 4.4 Gstreamer

[https://funvision.blogspot.com/2020/08/compile-opencv-4-with-cuda-and.html](/blog/compile-opencv-4-cuda-gstreamer-windows/)

[Image: gstreamer opencv 4.4]
