Thanks to a partnership between Collabora and Huawei is now possible to build Gstreamer with just the features required for a specific application, reducing the binary size for space-constrained embedded systems.
Gstreamer is a very popular open-source multimedia framework used in a wide variety of projects and products, and with an impressive number of features spread over 30 libraries and more than 1600 elements in 230 plugins. This is not a problem on desktop PC and most smartphones, but the size of the binary may be too large for some systems, and until recently it was no easy way to customize GStreamer build for a specific application. But Collabora changed the code to allow gst-build to generate a minimal GStreamer build.
-Dgst-full-libraries=. The plugins are then automatically included according to the configuration and the dependencies available. Here’s an example:
$ meson build-gst-full \
The important part is the
-Dauto_features=disabled line that disables automatic features selection, and then allows us to select specific features within the selected plugin(s).
All of this is already included in Gstreamer 1.18. So what did Collabora do exactly? They added five new options to Gstreamer menu to provide better granularity namely:
- gst-full-plugins – Select the plugin you’d like to include. By default, all the plugins will be enabled by the build process, and at least one must be passed to avoid building all.
- gst-full-elements – Select the element(s) using the
- gst-full-typefind-functions – Select the typefind(s) using the
- gst-full-device-providers – Select the decide-provider(s) using the
- gst-full-dynamic-types – Select the dynamic-type(s) using the
Element, typefind, device-provider, and dynamic type are all plugin features that are defined in Gstreamer documentation.
To showcase the solution, Collabora first built Gsteamer will all options resulting in a 49.2 MB gstreamer-full static library, following by a tailored build with just three elements namely filesrc,fakesink, andidentity:
$ meson build-gst-full --reconfigure -Dgst-full-plugins=coreelements '-Dgst-full-elements=coreelements:filesrc,fakesink,identity' '-Dgst-full-libraries='
$ ninja -C build-gst-full
That ended up being just 3.2 MB in size, or a 93.5% reduction in size. Not too bad!
You’ll find more details about Collabora implementation in the announcement blog post.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.