I am trying to implement stop feature for live video streaming using node-media-server.
Basically I want to stop node-media-server completely, restart it later.
const NodeMediaServer = require("node-media-server");
let config = {
logType: 3,
rtmp: {
port: rtmpPort,
chunk_size: 60000,
gop_cache: true,
ping: 60,
ping_timeout: 30,
},
http: {
port: httpPort,
allow_origin: "*",
},
relay: {
ffmpeg: "/usr/bin/ffmpeg",
tasks: [
{
app: "cctv",
mode: "static",
edge: "rtsp://" + cameraUrl + "/h264_ulaw.sdp",
name: "uterum",
rtsp_transport: "udp",
},
],
},
};
let nms = new NodeMediaServer(config);
nms.run();
I see on the project github that there is a stop method.
Have you try to use it ?
https://github.com/illuspas/Node-Media-Server/blob/master/node_media_server.js
nms.stop();
Answer to comment:
Goto the github repo :
Express file is the app.js
Inside it you see
const NodeMediaServer = require('./'); ... let nms = new NodeMediaServer(config) nms.run();
You see the NodeMediaServer ?
There is another file in the same folder node_media_server.js
which exports module.exports = NodeMediaServer
Just a look at this file and you see the stop method.
That's all.