Building Qt-GStreamer
-
Hello,
I have spent a few days resolving problems with qt-GStreamer and so I thought I would share my work so others might be able to benefit.
This is more of a guide of how I built it but also leaves some questions that I don't know the answer to.
GStreamer can grab many different sources of video and so is very useful as a plugin for
use in Qt.I am using Qt 5.7.1 with GStreamer 1.10.2 (32-bit-developer)
Download the qt-gstreamer Git Repository from here:
https://cgit.freedesktop.org/gstreamer/qt-gstreamerYou will need to have Git (https://git-scm.com/downloads) installed on your machine. I
also use the nice GUI from Attlasian – Source Tree: https://www.atlassian.com/software/
sourcetreeOnce you have qt-gstreamer downloaded to a directory, you will ned a lot of things
installed in order to build it.You will need to install CMake from here:
https://cmake.org/download/You obviously will need GStreamer. Qt-GStreamer didn’t like the 64bit version of
GStreamer, so I would stick with the 32bit version (x86):
https://gstreamer.freedesktop.org/data/pkg/windows/You also need to install Boost from here:
http://www.boost.org/And also the Glib / GObject from GTK+ http://www.gtk.org/
This wasn’t so straight forward because there isn’t an installer from gtk.org. You have to
download MSYS2 installer from here:
https://msys2.github.io/
Then you have to run a few commands with MSYS2 to install everything. These are all the
commands that I run that got it to work.
pacman -Sy pacman
pacman –Syu (keep running this until it says there is nothing left to update)
pacman -S mingw-w64-x86_64-toolchain
The last command installs the toolchain – don’t ask me what that is. There is more
information here: https://blogs.gnome.org/nacho/2014/08/01/how-to-build-your-gtkapplication-
on-windows/Now you should be ready to build qt-gstreamer!
Open up a command line and cd to the qt-gstreamer directory.
Now run:
$ mkdir build && cd build
$ cmake .. -G "Visual Studio 12 2013" -DCMAKE_INSTALL_PREFIX=\DEV
\GStreamer\qt-gstreamer -DQT_VERSION=5 -Wno-devThis tells CMake to use QT Version 5 and to suppress the CMake warnings for developers
and to use Visual Studio 2013 Cmake generator.
If everything works then you should get a list of all the dependencies that you do have and
a list of some things built by CMake. If it doesn’t work then you will get a list of missing
Requirements on the command line and also in the build directory in a file called
Requirements. If this happens, then install the missing requirements and delete everything
in the build directory before trying again.Now you should have a full build directory. Open up the QtGStreamer.sln file in Visual
Studio 2013 and choose Release Mode and then choose Build->Build Solution. This will
build a lot of things. I still got a few build failures but it was usable enough for me.
I wanted to run the QMLPlayer2 example, so I went straight to this solution:
qt-gstreamer\build\examples\qmlplayer2
and opened the qtgst-example-qmlplayer2.slnNow you can build that in release mode and you will have the executable in this directory:
qt-gstreamer\build\examples\qmlplayer2\ReleaseRun: QT_DIR\bin\Windeployqt.exe to pull in all the dependencies.
$ cd QT_DIR\bin
$ windeployqt.exe C:\DEV\qt-gstreamer\build\examples\qmlplayer2\ReleaseThis should fill up your qmlplayer2\Release folder with all the dll files and folders required
to deploy the qmlplayer on another machine.For some reason this didn’t pull in all the dependencies for me and I had to manually add
these folders:
QT_DIR/qml/QtQuick2.0
Also requires the QtGStreamer folder from
qt-gstreamer\build\src\qml\quick2\QtGStreamer
Requires Qt5OpenGL.dll file from QT_DIR\bin\Qt5openGL.dll
GStreamer also requires this file in this directory but I don’t know where this comes from:
C:\gstreamer\1.0\x86\lib\gstreamer-1.0\libgstqt5videosink.dllIt is probably an extra installation option with GStreamer.
If everything works then you should see a cartoon about a bunny start playing.
Other notes: When I first ran this on my machine I got a green screen instead of the
video. This turned out to be my Intel graphics card wasn’t good enough for it. Luckily I had
another graphics card already installed on my machine I just wasn’t using it x-(Hope this helps somebody. Please contribute any further information.
Regards,
Michael -
Hi,
You should maybe consider converting this to a Wiki article, forum posts don't stay visible in the long run.
-
Thanks for sharing your guide. I don't know why I'm having a hard time building this on Windows 10. I ran:
cmake .. -G "Visual Studio 14 2015" -DCMAKE_INSTALL_PREFIX=\Programs\GStreamer\qt-gstreamer -DQT_VERSION=5 -Wno-dev -DCMAKE_PREFIX_PATH=C:/Qt/5.11.0/msvc2015
which succeeded until
-- Could NOT find GLIB2 (missing: GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) -- Could NOT find GObject (missing: GOBJECT_INCLUDE_DIR GOBJECT_LIBRARIES) ... ----------------------------------------------------------------------------- -- The following REQUIRED packages could NOT be located on your system. -- You must install these packages before continuing. ----------------------------------------------------------------------------- * GLib <http://www.gtk.org/> Required to build QtGLib * GObject <http://www.gtk.org/> Required to build QtGLib
I used MSYS2 to install GTK+ in C:\Programs\gtk\gtk-3.19 but I might not have the necessary environment variables or paths that must be defined. I don't know if they were supposed to be created during installation or if I'm supposed to create or define them.
The file C:\Programs\qt-gstreamer\cmake\modules\FindGLIB2.cmake contains
find_path(GLIB2_MAIN_INCLUDE_DIR glib.h PATH_SUFFIXES glib-2.0 HINTS ${PKG_GLIB_INCLUDE_DIRS} ${PKG_GLIB_INCLUDEDIR})
so to the environment variable "PKG_CONFIG_PATH" I added "C:\Programs\gtk\gtk-3.19\include" because glib.h is in "C:\Programs\gtk\gtk-3.19\include\glib-2.0".
Something I found that doesn't seem right is what is in C:\Programs\gtk\gtk-3.19\lib\pkgconfig\glib-2.0.pc which contains
prefix=/opt exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include
which makes this appear to be for linux, not my Windows installation.
What seems to be more appropriate is what I found in C:\gstreamer\1.0\x86\lib\pkgconfig\glib-2.0.pc which containsprefix=/c/gstreamer/1.0/x86 exec_prefix=${prefix} libdir=/c/gstreamer/1.0/x86/lib includedir=${prefix}/include
but when I replaced the previous path with "C:\gstreamer\1.0\x86\lib\pkgconfig" in "PKG_CONFIG_PATH", this didn't change the symptoms.
If you could let me know what I might be missing that would let cmake know where to find GLib/GObject, I'd appreciate it.
-
Hi Jward,
I can't remember having problems with this specifically.
Only thing I could suggest if you have installed GLib and GObject is to manually define environment variables for GLIB2_LIBRARIES, GLIB2_MAIN_INCLUDE_DIR, GOBJECT_INCLUDE_DIR and GOBJECT_LIBRARIES.
Regards,
Michael