A high performance RTMP Server framework implementation
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();
ffmpeg -i test.mp4 -f flv -vcodec h264 -acodec aac "rtmp://127.0.0.1/living/streamName"
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>
You can view docs here