Skip to content

A high performance RTMP Server framework implementation

License

Notifications You must be signed in to change notification settings

xRoier/SharpRtmp

 
 

Repository files navigation

SharpRtmp

A high performance RTMP Server framework implementation

Getting started

Code

Program.cs

using SharpRtmp.Hosting;
using System;
using System.Net;

RtmpServer server = new RtmpServerBuilder()
    .UseStartup<Startup>()
    .Build();
await server.StartAsync();

Startup.cs

using Autofac;
using SharpRtmp.Hosting;

namespace SharpRtmp.Example;

class Startup : IStartup
{
    public void ConfigureServices(ContainerBuilder builder)
    {
    }
}

Build a server like this to support websocket-flv transmission

RtmpServer server = new RtmpServerBuilder()
    .UseStartup<Startup>()
    .UseWebSocket(c =>
    {
        c.BindEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 8080);
    })
    .Build();

push video file using ffmpeg

ffmpeg -i test.mp4 -f flv -vcodec h264 -acodec aac "rtmp://127.0.0.1/living/streamName"

play rtmp stream using ffplay

ffplay "rtmp://127.0.0.1/living/streamName"

play flv stream using flv.js by websocket

<video id="player"></video>

<script>

    if (flvjs.isSupported()) {
        var player = document.getElementById('player');
        var flvPlayer = flvjs.createPlayer({
            type: 'flv',
            url: "ws://127.0.0.1/websocketplay/streamName"
        });
        flvPlayer.attachMediaElement(player);
        flvPlayer.load();
        flvPlayer.play();
    }
</script>

Dive in deep

You can view docs here

About

A high performance RTMP Server framework implementation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%