This open-source project provides an implementation of an RTMP live streaming server which allows you to build your own live streaming server using .NET.
- 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.
- Remuxing RTMP streams into HLS/DASH streams: Allows you to remux 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.
- Native AOT support
- Kubernetes operator
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;
await using var server = LiveStreamingServerBuilder.Create()
.ConfigureLogging(options => options.AddConsole())
.Build();
await server.RunAsync(new IPEndPoint(IPAddress.Any, 1935));
Run the application
dotnet run
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
- Open OBS Studio and go to "Settings".
- In the "Settings" window, select the "Stream" tab.
- Choose "Custom" as the "Service".
- Enter "Server":
rtmp://localhost:1935/liveand "Stream Key":demo. - Click "OK" to save the settings.
- Click the "Start Streaming" button in OBS Studio to begin sending live stream to the RTMP server.
Use the following command to play the live stream using FFplay
ffplay rtmp://localhost:1935/live/demo
- Open VLC Media Player.
- Go to the "Media" menu and select "Open Network Stream".
- In the "Network" tab, enter the URL:
rtmp://localhost:1935/live/demo. - Click the "Play" button to start playing the live stream.
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;
var builder = WebApplication.CreateBuilder(args);
await using var liveStreamingServer = LiveStreamingServerBuilder.Create()
.ConfigureRtmpServer(options => options.AddFlv())
.ConfigureLogging(options => options.AddConsole())
.Build();
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"
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
Please refer to the LiveStreamServerNet.HlsDemo
Please refer to the LiveStreamServerNet.StandaloneDemo

