• Stars
    star
    208
  • Rank 189,015 (Top 4 %)
  • Language
    C#
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A high performance and scalable RTMP live streaming application framework

master is not a stable branch, you may want to see the latest tag

Harmonic

A high performance RTMP live streaming application framework

Getting started

Code

Program.cs

using Harmonic.Hosting;
using System;
using System.Net;

namespace demo
{
    class Program
    {
        static void Main(string[] args)
        {
            RtmpServer server = new RtmpServerBuilder()
                .UseStartup<Startup>()
                .Build();
            var tsk = server.StartAsync();
            tsk.Wait();
        }
    }
}

StartUp.cs

using Autofac;
using Harmonic.Hosting;

namespace demo
{
    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