How to use node-media-server - 5 common examples

To help you get started, we’ve selected a few node-media-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nzws / knzklive-publish-server / src / index.js View on Github external
mp4Flags: '[movflags=faststart]'
    });
  }

  config.trans = {
    ffmpeg: conf.ffmpeg_path,
    tasks
  };
}

function getLastFile(dir) {
  const files = fs.readdirSync(dir);
  return files[files.length - 1];
}

const nms = new NodeMediaServer(config);
nms.run();

nms.on('prePublish', (id, StreamPath, args) => {
  // eslint-disable-next-line no-console
  console.log(
    '[NodeEvent on prePublish]',
    `id=${id} StreamPath=${StreamPath} args=${JSON.stringify(args)}`
  );
});

nms.on('donePublish', (id, StreamPath, args) => {
  // eslint-disable-next-line no-console
  console.log(
    '[NodeEvent on donePublish]',
    `id=${id} StreamPath=${StreamPath} args=${JSON.stringify(args)}`
  );
github sieuhuflit / live-tream-rtmp-server / server.js View on Github external
allow_origin: '*'
  },
  trans: {
    ffmpeg: '/usr/local/bin/ffmpeg',
    tasks: [
      {
        app: 'live',
        ac: 'aac',
        mp4: true,
        mp4Flags: '[movflags=faststart]'
      }
    ]
  }
};

var nms = new NodeMediaServer(nodeMediaServerConfig);
nms.run();

nms.on('getFilePath', (streamPath, oupath, mp4Filename) => {
  console.log('---------------- get file path ---------------');
  console.log(streamPath);
  console.log(oupath);
  console.log(mp4Filename);
  utils.setMp4FilePath(oupath + '/' + mp4Filename);
});

nms.on('preConnect', (id, args) => {
  console.log(
    '[NodeEvent on preConnect]',
    `id=${id} args=${JSON.stringify(args)}`
  );
  // let session = nms.getSession(id);
github nzws / knzklive-publish-server / index.js View on Github external
if (conf.ffmpeg_path) {
  config["trans"] = {
    ffmpeg: conf.ffmpeg_path,
    tasks: [
      {
        app: 'live',
        ac: 'aac',
        hls: true,
        hlsFlags: '[hls_time=1:hls_list_size=2:hls_flags=delete_segments]',
      }
    ]
  };
}

const nmcs = new NodeMediaServer(config);
nmcs.run();

nmcs.on('prePublish', (id, StreamPath, args) => {
  console.log('[NodeEvent on prePublish]', `id=${id} StreamPath=${StreamPath} args=${JSON.stringify(args)}`);
});

nmcs.on('donePublish', (id, StreamPath, args) => {
  console.log('[NodeEvent on donePublish]', `id=${id} StreamPath=${StreamPath} args=${JSON.stringify(args)}`);
  axios.get(`${config.knzklive.api_endpoint}publish.php?token=${args.token}&live=${StreamPath}&authorization=${config.knzklive.api_key}&mode=done_publish`).then(response => {
    console.log('[donePublish]', response);
  }).catch(error => {
    console.log('[donePublish]', error);
  })
});

nmcs.on('postPlay', (id, StreamPath, args) => {
github godka / kurento-rtmp / server.js View on Github external
if (sessions[sessionId]) {
        console.info('Sending candidate');
        var webRtcEndpoint = sessions[sessionId].webRtcEndpoint;
        webRtcEndpoint.addIceCandidate(candidate);
    }
    else {
        console.info('Queueing candidate');
        if (!candidatesQueue[sessionId]) {
            candidatesQueue[sessionId] = [];
        }
        candidatesQueue[sessionId].push(candidate);
    }
}

app.use(express.static(path.join(__dirname, 'static')));
var nms = new NodeMediaServer(rtmp_server_config);
nms.run();
process.on('uncaughtException', function (error) {
    console.log(error);
});
github notedit / media-server-go-demo / webrtc-to-rtmp / rtmp-server / server.js View on Github external
const { NodeMediaServer } = require('node-media-server');


const config = {
  rtmp: {
    port: 1935,
    chunk_size: 128,
    gop_cache: true,
    ping: 60,
    ping_timeout: 30
  }
};

var nms = new NodeMediaServer(config)
nms.run();

node-media-server

A Node.js implementation of RTMP Server

MIT
Latest version published 6 months ago

Package Health Score

58 / 100
Full package analysis

Popular node-media-server functions