We're hiring!
*

Building GStreamer on Windows

Aaron Boxer avatar

Aaron Boxer
November 26, 2019

Share this post:

Given GStreamer's roots in the Linux/GTK world, Windows has seemed at times like a second-class citizen when it came to hacking GStreamer code. With the advent of meson and gst-build, however, this is no longer the case. It is now possible to set up a Windows development environment that rivals the finest Linux has to offer, with full support for Visual Studio debugging into the library.

Here's how:

Setup

We are going to use not one but two IDEs ! Vi vs EMACS people : Nothing to see here, move along.

  1. gst-build pre-requisites for Windows
  2. Visual Studio 2019 community edition
  3. Eclipse CDT (you will need to have a Java JRE/JDK installed) (optional)

I also recommend the superb Git client Git Extensions.

Important: once Git is installed, ensure that line endings are configured to core.autocrlf in your Git configuration. Otherwise, you may get Windows line endings breaking GStreamer shell scripts.

Next, we set up a few environment variables (note the backslash at the end of each path except the last one):

Environment Variable Value
SOURCE_DIR c:\\PATH\TO\YOUR\SOURCE\
GSTREAMER_1_0_ROOT_X86_64 %SOURCE_DIR%x86_64\
GST_SRC_BUILD_PATH %SOURCE_DIR%gst-build\build\subprojects\
GST_PLUGIN_PATH %GST_SRC_BUILD_PATH%gst-plugins-good;%GST_SRC_BUILD_PATH%gst-plugins-bad;%GST_SRC_BUILD_PATH%gst-plugins-base

Now, we will clone gst-build into our SOURCE_DIR directory, like so:

cd %SOURCE_DIR%
git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git

And finally we add the following entry to our PATH environment variable

%GSTREAMER_1_0_ROOT_X86_64%bin

Build

  1. Open a Visual Studio x64 command prompt:

Visual Studio 2019 \ x64 Native Tools Command Prompt

  1. Run meson on gst-build:
cd %SOURCE_DIR%gst-build
meson --prefix=%GSTREAMER_1_0_ROOT_X86_64% build

Option 1: Build with from the command line

  1. Run ninja to build gst-build
    ninja -C build

Jump to step 8.

Option 2: Build GStreamer with Eclipse

  1. Launch Eclipse from the prompt:

C:\\PATH\TO\ECLIPSE\eclipse.exe

  1. Under the Eclipse File \ Import menu, choose import C++\Existing code as Makefile Project and select the %SOURCE_DIR%gst-build folder. You now have a fully-indexed, fully searchable project containing GStreamer code for base, plugins etc. Since gst-build is a big project, and Eclipse uses a lot of resources, we can filter out the build folder from the project by:

    1. typing Alt Enter to open the project Properties

    2. Under Resource \ Resource Filters, add a filter to exclude the build folder (choose the Project Relative Path setting)

  2. Eclipse by default does not save files before building. Under Windows \ Preferences \ General \ Workspace \ Build. select Save automatically before build

  3. Right click on the gst-build project, select Properties \ C++ Build, un-check Use default build command and enter ninja -C build as the build command

  4. Ctrl + B to build GStreamer

  5. When the build is complete, return to the x64 command prompt and run ninja -C build install to install GStreamer to GSTREAMER_1_0_ROOT_X86_64

Hack

  1. Open your project in Visual Studio. Your compile and link settings should use the GSTREAMER_1_0_ROOT_X86_64 environment variable to ensure you are linking to the gst-build version of GStreamer

  2. To set breakpoints in GStreamer, open the file from the appropriate sub-project inside GST_SRC_BUILD_PATH and set the breakpoint

  3. To modify GStreamer code, edit the code and build in Eclipse (or your favorite editor) - your Visual Studio project will automagically pick up the changes when it next runs. Don't forget to run the ninja -C build install step.

Push

  1. Inside GST_SRC_BUILD_PATH, the Git repositories can be modified to point to different branches. The only issue here is when executing ninja -C build update, which will stop on the modified repositories

  2. The only tool missing on Windows is gst-indent. To indent new code, we need to:

    1. Install Windows Subsystem for Linux (WSL), with Ubuntu 18.04 and GNU indent 2.2.11
    2. Open WSL
    3. sudo apt install git autoconf autopoint libtool make texi2html
    4. mkdir src && cd src
    5. wget https://ftp.gnu.org/gnu/indent/indent-2.2.11.tar.gz
    6. tar xvzf indent-2.2.11.tar.gz
    7. cd indent-2.2.11 && ./configure
    8. make && sudo make install

Now we can indent new code in the Ubuntu terminal like so:

/mnt/c/PATH/TO/SOURCE/gst-build/subprojects/gstreamer/tools/gst-indent /mnt/c/PATH/TO/FILE.c

Finally, we take the potentially dangerous step of removing the gst-indent pre-commit hook from the GStreamer sub-project we are working on:

  1. cd %SOURCE_DIR%gst-build\subprojects\SOME_GST_SUBPROJECT\.git\hooks
  2. del pre-commit

We must now be careful to remember to run gst-indent from the Ubuntu terminal before committing.

Now sit back and give yourself a big high-five !

If you have any questions about GStreamer on Windows or any other platform, please contact us.

Comments (4)

  1. yair:
    Nov 27, 2019 at 07:50 AM

    thank you, excellent timing.
    just had to do a couple of things to get it working for me.
    1. disable MSDK -Dgst-plugins-bad:msdk=disabled
    (still haven't installed the media SDK on my system and ninja was complaining on libmfx.lib missing)
    2. libxml2 was not passing
    FAILED: subprojects/libxml2-2.9.7/
    2a. had to disable GES in meson_options.txt
    2b. remove subprojects/libxml.wrap

    probably better way to do all this...

    Reply to this comment

    Reply to this comment

    1. Aaron Boxer:
      Nov 27, 2019 at 05:39 PM

      Hi Yair,
      Thanks for your feedback! For the MSDK issue, I do get an error posted about missing the Intel Media SDK,
      but it doesn't prevent building GStreamer or running any pipelines. And I didn't see the GES or libxml
      issues you mentioned, perhaps this is a conflict from a previous GStreamer binary install ?
      Cheers,
      Aaron

      Reply to this comment

      Reply to this comment

      1. yair:
        Nov 29, 2019 at 10:11 AM

        didn't mention i'm running on ubuntu 18LTS.
        the further i go into gst i feel a docker approach for building is the best solution.
        i started digging into gst-ci but im missing some knowhow on best method to run it locally.
        anyways, your article was just in time for me. i'm a happy reader.

        Reply to this comment

        Reply to this comment

        1. Aaron Boxer:
          Dec 02, 2019 at 01:47 PM

          Yes, docker would be great - you might want to open an issue for this on the GStreamer Gitlab site.
          I'm glad you found this post helpful !

          Reply to this comment

          Reply to this comment


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Search the newsroom

Latest Blog Posts

Building GStreamer on Windows

26/11/2019

With the advent of meson and gst-build, it is now possible to set up a GStreamer Windows development environment that rivals the finest…

Zink: Fall Update

24/10/2019

I recently went to XDC 2019, where I gave yet another talk about Zink. I kinda forgot to write a blog-post about it, so here’s me trying…

Adding stateless support to vicodec

09/10/2019

Prior to joining Collabora, I took part in Round 17 of the Outreachy internships, to work on the virtual drivers in the media subsystem…

Why HDCP support in Weston is a good thing

03/10/2019

What HDCP is, and why supporting HDCP in Weston is justified in both an economical and technical context.

Virglrenderer and the state of virtualized virtual worlds

28/08/2019

With the release of virglrenderer 0.8.0, getting accelerated OpenGL within a virtual machine (VM) made a big leap forward. Since virglrenderer-0.7.0,…

ROCK Pi and an easy place: Panfrost & Wayland on a Rockchip board

06/08/2019

Ongoing work on the reverse-engineered Panfrost OpenGL ES driver for Arm Mali GPUs has turned the RK3399 SoC into a very attractive platform…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2019. All rights reserved. Website sitemap.