To convert rtsp stream to websocket stream for multi view purpose
- RTSP Stream to Websocket
- RTSP Stream to Recording(Download & Storing into the file location)
- RTSP Stream to Screenshot(Take picture from Stream)
$ npm i node-ffmpeg-stream
Stream = require('node-ffmpeg-stream').Stream;
stream = new Stream({
name: 'name',//name that can be used in future
url: 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4', //Stream URL
wsPort: 7070, //Streaming will be transferred via this port
options: { // ffmpeg options
'-stats': '', // print progress report during encoding, can be no value ''
'-r': 30 // frame rate (Hz value, fraction or abbreviation) - By default it set to 30 if no value specified
}
})
This method should be called when you have 0 socket connection
or to disconnect to all the viewers(sockets).
stream.stop();
<html>
<body>
<canvas id="stream"></canvas>
</body>
<script type="text/javascript" src="jsmpeg.min.js"></script>
<script type="text/javascript">
player = new JSMpeg.Player('ws://localhost:7070', {
canvas: document.getElementById('stream') // stream should be a canvas DOM element
})
</script>
</html>
RecordNSnap = require('node-ffmpeg-stream').RecordNSnap;
var input ={
"url": "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4",
"second": "60", // by default 5 sec
"filePath": "D:\\Records\\", // by default ""
"fileName": "test5.mp4", // your output filename with extension like mp4,avi & et.,
"fileMimeType":"video/mp4", // Mime type for download file via javascript & advanced javascript
"recordType":"download" // can be download or store
}
objRecordNSnap=new RecordNSnap();
objRecordNSnap.recordVideo(input,function(resp){
res.send(resp);
})
input = {
"url": "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4",
"second": "1",
"filePath": "F:\\",
"fileName": "test5.mp4",
"fileMimeType":"video/mp4",
"recordType":"download"
}
input = {
"url": "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4",
"second": "1",
"filePath": "F:\\",
"fileName": "test5.mp4",
"fileMimeType":"video/mp4",
"recordType":"store"
}
RecordNSnap = require('node-ffmpeg-stream').RecordNSnap;
var input = {
"url": "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4",
"imagePath": "F:\\", // by default ""
"imageName": "test2.jpeg", // your output filename with extension like mpeg,png & etc.,
"imageMimeType":"image/jpeg", // Mime type for download file via javascript & advanced javascript
"snapType":"download" // can be download or store
}
snap = new RecordNSnap();
snap.takeSnap(input,function(resp){
res.send(resp);
});
input = {
"url": "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4",
"imagePath": "F:\\",
"imageName": "test2.jpeg",
"imageMimeType":"image/jpeg",
"snapType":"download"
}
input = {
"url": "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4",
"imagePath": "F:\\",
"imageName": "test2.jpeg",
"imageMimeType":"image/jpeg",
"snapType":"store"
}
- FFMPEG.exe - exe file should be in same place of js file
- jsmpeg.min.js