GStreamer-Sharp for .NET Core - GStreamer C# bindings
This library is .NET Core bindings for GStreamer made on top of the original gstreamer-sharp bindings. The library uses gstreamer-sharp sources as a submodule made from gstreamer-sharp GitHub mirror.
GStreamer is a library for constructing graphs of media-handling components.
GStreamer-Sharp is a .NET/mono binding for Gstreamer
generated from gobject-introspection data using the bindinator. GStreamer-sharp currently wraps the API exposed by Gstreamer 1.12 and is compatible with newer gstreamer versions. It was developed
under GSoC 2014 for the mono organization. gstreamer-sharp covers
the core and base gstreamer libraries.
You need to have Gstreamer and its plugins binaries installed and added to PATH environment variable!
On Windows, gstreamer-sharp works only if you installed a MiniGW build.
It doesn’t work with MSVC build (has ‘msvc’ in .msi file name). If using Chocolatey package for GStreamer, it currently installs an MSVC build which won’t work with this library.
We tested with gstreamer-1.0-mingw-x86_64-1.16.2.
When installing GStreamer on Windows, in addition to default components, select “Gstreamer 1.0 libav wrapper”.
%GSTREAMER_1_0_ROOT_X86_64%\bin (C:\gstreamer\1.0\x86_64\bin) must be added to PATH environment variable.
You may also need to create GST_PLUGIN_PATH environment variable pointing to %GSTREAMER_1_0_ROOT_X86_64%\lib\gstreamer-1.0 (C:\gstreamer\1.0\x86_64\lib\gstreamer-1.0).
1) Create a .NET Core project. You need one for .NET Core SDK 3.1 or above.
dotnet new console
If making a class library, make sure it targets .NET Core 3.1+:
dotnet new classlib -f netcoreapp3.1
2) Add gstreamer-sharp-netcore NuGet package to your .NET Core app.
dotnet add package gstreamer-sharp-netcore
3) Here is a very minimal app (BasicTutoria1). You may also look at how they do it in more Samples.
using System;
using Gst;
namespace GstreamerSharp
{
class Program
{
public static void Main (string[] args)
{
// Initialize Gstreamer
Application.Init(ref args);
// Build the pipeline
var pipeline = Parse.Launch("playbin uri=http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4");
// Start playing
pipeline.SetState(State.Playing);
// Wait until error or EOS
var bus = pipeline.Bus;
var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Eos | MessageType.Error);
// Free resources
pipeline.SetState (State.Null);
}
}
}
1) Clone the repository recursively (notice —recurse flag)
2) Build the project using dotnet command line or a compatible IDE of your choice (I use Visual Studio Code on Windows, macOS and Linux)
git clone https://github.com/vladkol/gstreamer-netcore --recurse
cd gstreamer-netcore
dotnet build
Any operating system and environment that GStreamer and .NET Core 3.1 can run on. We tested on Windows 10 1909, macOS Catalina and Ubuntu 18.04.
GStreamer-Sharp has a plenty of samples, and we also included a few:
Rudimentary video player made with Avalonia UI
GStreamer video processing pipeline, GStreamer video processing pipeline with raw sample handling, for an RTSP stream, web camera, or pretty much any GStreamer pipeline. If you want to create a real-time machine learning pipeline, it’s your starting point.
gstreamer-sharp is licensed under the LGPL 2.1, same as many parts of GStreamer and gstreamer-sharp.