Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.
/ gstreamer-netcore Public archive

GStreamer-Sharp for .NET Core - GStreamer C# bindings

License

Notifications You must be signed in to change notification settings

vladkol/gstreamer-netcore

Repository files navigation

GStreamer-Sharp for .NET Core

GStreamer bindings for .NET Core

GStreamer logo

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.

NuGet Badge

GStreamer is a library for constructing graphs of media-handling components.

What exactly can I do with GStreamer? GStreamer supports a range of scenarios from simple audio and video playback and streaming to complex audio (mixing) and video (non-linear editing) processing.

Applications can take advantage of advances in codec and filter technology transparently. Developers can add new codecs and filters by writing a simple plugin with a clean, generic interface.

Even more details

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.

Prerequisites

  • .NET Core 3.1+ runtime for running the apps or .NET Core SDK 3.1+ for development
  • gstreamer core with "base" and "good" plugins 1.14 or higher (you may need "libav" wrapper or "bad"/"ugly" plugins for some features). What is that?

You need to have Gstreamer and its plugins binaries installed and added to PATH environment variable!

If you develop on Windows, please read this

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).

Quick Start

  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  
  1. Add gstreamer-sharp-netcore NuGet package to your .NET Core app.
dotnet add package gstreamer-sharp-netcore
  1. 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);
		}
	}
}

Building

  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

Supported Platforms

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.

Samples

GStreamer-Sharp has a plenty of samples, and we also included a few:

  • Console app demostrating different audio and video playback scenarios

  • 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.

License

gstreamer-sharp is licensed under the LGPL 2.1, same as many parts of GStreamer and gstreamer-sharp.

Releases

No releases published

Packages

No packages published

Languages