Giter Site home page Giter Site logo

josephnhtam / live-streaming-server-net Goto Github PK

View Code? Open in Web Editor NEW
40.0 3.0 8.0 2.97 MB

A .NET implementation of RTMP live streaming server, supporting HTTP-FLV, WebSocket-FLV, HLS, DASH and more.

License: MIT License

C# 95.32% JavaScript 0.04% HTML 0.05% TypeScript 4.37% CSS 0.01% Dockerfile 0.10% Makefile 0.11%
csharp dotnet live-streaming rtmp rtmp-server dotnet-library livestream flv http-flv websocket-flv

live-streaming-server-net's Introduction

Live-Streaming-Server-Net

build and test Nuget License: MIT

This repository contains an implementation of RTMP server which allows you to build your own live streaming server using .NET.

A more detailed documentation is currently under construction.

Features

  • RTMP/RTMPS protocol: Supports the RTMP and RTMPS protocols for streaming audio, video, and data.
  • HTTP-FLV/WebSocket-FLV with ASP.NET CORE: Provides support for serving FLV live streams using HTTP-FLV and WebSocket-FLV protocols within an ASP.NET Core application.
  • Transmuxing RTMP streams into HLS/DASH streams: Allows you to transmux RTMP streams into HLS (HTTP Live Streaming) or DASH (Dynamic Adaptive Streaming over HTTP) streams.
  • GOP caching: Supports caching the Group of Pictures (GOP) to ensure immediate availability of live streaming content.
  • Custom authorization: Enables you to implement custom authorization mechanisms for accessing live streams.
  • Admin panel: Includes an admin panel that provides an user interface for managing and monitoring the live streaming server.
  • Cloud Storage Integration: Enabling real-time uploading of HLS files to cloud storage services like Azure Blob Storage, Google Cloud Storage, and AWS S3, which ensures scalable and efficient HLS stream distribution through CDN.

In-Progress

  • Custom Kubernetes Operator and Kubernetes Integration: The objective is to achieve automatic horizontal autoscaling by scaling out the pods when more streams are published, and scaling in the pods when streams are deleted, all without affecting the existing connections.
  • Redis Integration: Integrate with Redis to share stream information among pods in the fleet.

Roadmap

  • Edge Server: Although edge servers are not necessary for serving HLS, they are required for serving RTMP and FLV streams in a cluster configuration.

Quick Start

Run the RTMP Server

Create a .NET 8 console application project and add the dependencies

dotnet new console
dotnet add package LiveStreamingServerNet
dotnet add package Microsoft.Extensions.Logging.Console

Program.cs

using LiveStreamingServerNet;
using Microsoft.Extensions.Logging;
using System.Net;

using var server = LiveStreamingServerBuilder.Create()
    .ConfigureLogging(options => options.AddConsole())
    .Build();

await server.RunAsync(new IPEndPoint(IPAddress.Any, 1935));

Run the application

dotnet run

Publish a Live Stream

With FFmpeg

Use the following command to publish a video as the live stream using FFmpeg

ffmpeg -re -i <input_file> -c:v libx264 -c:a aac -f flv rtmp://localhost:1935/live/demo

With OBS Studio

  1. Open OBS Studio and go to "Settings".
  2. In the "Settings" window, select the "Stream" tab.
  3. Choose "Custom" as the "Service".
  4. Enter "Server": rtmp://localhost:1935/live and "Stream Key": demo.
  5. Click "OK" to save the settings.
  6. Click the "Start Streaming" button in OBS Studio to begin sending live stream to the RTMP server.

Play the Live Stream

With FFplay

Use the following command to play the live stream using FFplay

ffplay rtmp://localhost:1935/live/demo

With VLC Media Player

  1. Open VLC Media Player.
  2. Go to the "Media" menu and select "Open Network Stream".
  3. In the "Network" tab, enter the URL: rtmp://localhost:1935/live/demo.
  4. Click the "Play" button to start playing the live stream.

Serve FLV Live Streams

Create a ASP.NET CORE 8 Web API application project and add the dependencies

dotnet new webapi
dotnet add package LiveStreamingServerNet
dotnet add package LiveStreamingServerNet.Flv

Program.cs

using System.Net;
using LiveStreamingServerNet;
using LiveStreamingServerNet.Flv.Installer;
using LiveStreamingServerNet.Networking.Helpers;

using var liveStreamingServer = LiveStreamingServerBuilder.Create()
    .ConfigureRtmpServer(options => options.AddFlv())
    .ConfigureLogging(options => options.AddConsole())
    .Build();

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddBackgroundServer(liveStreamingServer, new IPEndPoint(IPAddress.Any, 1935));

var app = builder.Build();

app.UseWebSockets();
app.UseWebSocketFlv(liveStreamingServer);

app.UseHttpFlv(liveStreamingServer);

await app.RunAsync();

Run the application

dotnet run --urls="https://+:8080"

Play FLV Live Streams

Given a live stream is published to rtmp://localhost:1935/live/demo

HTTP-FLV

https://localhost:8080/live/demo.flv

WebSocket-FLV

wss://localhost:8080/live/demo.flv

Remux RTMP Streams into HLS Streams with FFmpeg

Please refer to the LiveStreamServerNet.HlsDemo

Admin Panel

Admin Panel

HTTP-FLV Preview

Please refer to the LiveStreamServerNet.StandaloneDemo

NuGet Packages

Package Latest Version
LiveStreamingServerNet
LiveStreamingServerNet.Standalone
LiveStreamingServerNet.AdminPanelUI
LiveStreamingServerNet.Flv
LiveStreamingServerNet.Networking
LiveStreamingServerNet.Rtmp
LiveStreamingServerNet.Transmuxer
LiveStreamingServerNet.Transmuxer.AmazonS3
LiveStreamingServerNet.Transmuxer.AzureBlobStorage
LiveStreamingServerNet.Transmuxer.GoogleCloudStorage
LiveStreamingServerNet.Utilities

live-streaming-server-net's People

Contributors

dependabot[bot] avatar josephnhtam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

live-streaming-server-net's Issues

How to use it ?

Hello! i don't know how to use it. Can you demo for a livestream video ?

Authentication Sample

Hi @josephnhtam this is really a great work!
I want to inject some mechanism for authentication, example -
My API server will give code to push stream, but before allowing push I want to verify the code. Can you share some sample how the inbuilt authentication can be used or customized. I could not find any sample for that on repository.

Also I am open to contribute some sample for the same if you allow, like db authentication or bearer etc, if you guide.

Vishal

Running On Docker

Hi @josephnhtam
when i try to run on docker with this "LiveStreamingServerNet.KubernetesPodDemo", added "EXPOSE 1935", then its started, when i try to stream, am getting below error. Also commented out Redis.

image

Delay on Streaming

am facing 15sec delay when running from IIS, is there any way to reduce the delay?

Excessive use of IServiceProvider

You have a very interesting approach to dependency injection, and coding in general.

The IServiceProvider has tripped me up several times when trying to work with the code. The nested dependencies make it difficult to understand which classes are actually used and where.

I'd suggest removing the IServiceProvider references and actually using the dependency injection built into Net Core properly. It will make the code easier to use, easier to test and easier to understand.

Microsoft recommendation for not using IServiceProvider

Minimize delay on displaying local RTMP-Stream

Hi, first of all thank you for this project!

I am using it in a .NET MAUI Application on iOS, where an iPhone is not only the RTMP-Server but also the Client, showing the RTMP-Livestream on the screen.

I want to show the stream along a view of the camera of the iPhone itself, my problem is the delay of ~2sec I get between both views. The only setting I found which could have impact was on RtmpServerConfiguration the setting EnableGopCaching. But changing it had no impact at all.

Is there any caching/delay/latency setting I've missed?

Thanks in advance!

Upload the files to Azure Blob

First of all thanks for the wonderful project, its very useful for me.

am using this to stream my desktop and store those stream to Azure blob. Its streaming the desktop, is there any way to upload the files to azure blob.?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.