GithubHelp home page GithubHelp logo

dony2100 / live-tream-rtmp-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sieuhuflit/live-tream-rtmp-server

0.0 1.0 0.0 1.31 MB

Live stream using RTMP for React Native

JavaScript 99.85% Shell 0.15%

live-tream-rtmp-server's Introduction

๐Ÿ“บ Live stream RTMP server

Live stream using RTMP for React Native App Live Stream

Client: https://github.com/sieuhuflit/react-native-live-stream-rtmp-example

Demo v2

Note: Here is demo for version 2.0

Demo v1

Note: Here is demo for version 1.0

Streamer Viewer

Feature

  • โœ… Live Stream with input username account
  • โœ… The video can replay
  • โœ… Live update status when Pending, On Live, and Finish live streaming process
  • โœ… Streamer and viewer can chat and send heart when livestream

Teachnology using

  • Using node-media-server

Prerequisite

Then start MongoDB. Then type the following to terminal

# mongo

Then switch to admin database

> use admin

Then create user admin

db.createUser({
  user: 'admin',
  pwd: '123456',
  roles: [
    { role: 'userAdminAnyDatabase', db: 'admin' },
    { role: 'dbAdminAnyDatabase', db: 'admin' },
    { role: 'readWriteAnyDatabase', db: 'admin' }
  ]
})

Get Start

yarn install
node server.js

Want to Replay video

Concept: After live stream finish, the mp4 file will generate and save to folder media/* folder. We need to do this step to get exact mp4 path information and save it to MongoDB.

Open this file node_modules/node_media_server/node_trans_session.js. Then import this to the top

const context = require('./node_core_ctx');

Then add this

context.nodeEvent.emit('getFilePath', this.conf.streamPath, ouPath, mp4FileName);

Under this line

Logger.log('[Transmuxing MP4] ' + this.conf.streamPath + ' to ' + ouPath + '/' + mp4FileName);

The result look similar like this

// ...
// ===> ADD THIS LINE
const context = require("./node_core_ctx");
// ...

class NodeTransSession extends EventEmitter {
  constructor(conf) {
    super();
    this.conf = conf;
  }

  run() {
    // ...
    // Rest of stuff
    // ...
    if (this.conf.mp4) {
      this.conf.mp4Flags = this.conf.mp4Flags ? this.conf.mp4Flags : '';
      let now = new Date();
      let mp4FileName = dateFormat('yyyy-mm-dd-HH-MM') + '.mp4';
      let mapMp4 = `${this.conf.mp4Flags}${ouPath}/${mp4FileName}|`;
      mapStr += mapMp4;
      Logger.log('[Transmuxing MP4] ' + this.conf.streamPath + ' to ' + ouPath + '/' + mp4FileName);

      // ===> ADD THIS LINE
      context.nodeEvent.emit("getFilePath", this.conf.streamPath, ouPath, mp4FileName);
    }

    //...
  }

Common Problem

1/ I can't replay the video ?

Sometimes the video can't replay, you need to wait a little bit wait the saving mp4 file process finish, then you can replay the video.

License

MIT

live-tream-rtmp-server's People

Contributors

sieuhuflit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.