Skip to content

This application provide livestream service for streaming, and merge 2 streams to 1 stream if you want to make AMA live.

Notifications You must be signed in to change notification settings

rintran720/rtmp-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTMP SERVICE

This application provide livestream service for streaming, and merge 2 streams to 1 stream if you want to make AMA live.

Install ffmpeg for RTMP to HLS transcoding

# On Ubuntu 18.04

$ sudo add-apt-repository ppa:jonathonf/ffmpeg-4
$ sudo apt install ffmpeg

# check version
$ ffmpeg --version

# You can download Windows builds from ffmpeg site.

Prerequisites

MongoDB

Make sure you have MongoDB installed on your system. We use Mongoose for accessing database. Check MongoDB docs on how to install MongoDB on your operating system.

Linux

Windows

Mac

Python 2.7

Make sure you have python 2.x installed and added to path.

Configuration

Change ffmpeg path in node media server configuration to your own installed path.

Also change secret string. It will be used for session encryption.

cd nodeStream && nano /server/config/default.js

const config = {
    server: {
        secret: 'kjVkuti2xAyF3JGCzSZTk0YWM5JhI9mgQW4rytXc',
        port : 3333
    },
    rtmp_server: {
        rtmp: {
            port: 1935,
            chunk_size: 60000,
            gop_cache: true,
            ping: 60,
            ping_timeout: 30
        },
        http: {
            port: 8888,
            mediaroot: './server/media',
            allow_origin: '*'
        },
        trans: {
            ffmpeg: '/usr/bin/ffmpeg',
            tasks: [
                {
                    app: 'live',
                    hls: true,
                    hlsFlags: '[hls_time=2:hls_list_size=3:hls_flags=delete_segments]',
                    dash: true,
                    dashFlags: '[f=dash:window_size=3:extra_window_size=5]'
                }
            ]
        }
    }
};

Install dependencies, build code and run server

$ npm install

# run webpack and watch for changes
$ npm run watch

# run node server with supervisor and watch for changes
$ npm run start

Call API

  1. Login

    [POST] localhost:3333/login with body:

{
  "email": "[email protected]",
  "password": "1234",
}
  1. Merge videos

    [POST] localhost:3333/streams/merge with body:

{
  "input1": "rtmp://127.0.0.1:1935/live/SybAUTK2Wc",
  "input2": "rtmp://127.0.0.1:1935/live/Hy1nhF2-q",
  "output": "rtmp://127.0.0.1:1935/live/B1zr10Cb9"
}

Streaming with OBS

Go to Settings > Stream. Select Custom service and rtmp://127.0.0.1:1935/live in server input. Enter your streaming key issued by NodeStream and click Apply. Click start streaming to broadcast your stream.

About

This application provide livestream service for streaming, and merge 2 streams to 1 stream if you want to make AMA live.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published