简体   繁体   中英

How to recorder a RTSP Stream

I'm using the node-rtsp-stream package and Websocket to make the transmission of my IP-Camera, and the visualization happens well, now I'd like to know how to record this transmission and I have no idea how to do this.

index.js in Server-side(NodeJS)

 const Stream = require('node-rtsp-stream'), stream = new Stream({ name: 'Garage-Camera', streamUrl: `rtsp://${meu_ip}:1030/user=${user}&password=${pass}&channel=1&stream=0.sdp?`, wsPort: 5000 })

in client-side

 <div> <canvas id="videoCanvas"></canvas> </div> <script src="jsmpeg.js"></script> <script> const ws = new WebSocket("ws://localhost:5000") const player = new jsmpeg(ws, { canvas: document.querySelector('#videoCanvas'), autoplay: true, audio: false, loop: true }) </script>

you can use the node-rtsp-recorder library and it's very simple to use it.

recording example

     const Recorder = require('node-rtsp-recorder').Recorder
 
     var rec = new Recorder ({
         url: 'rtsp://192.168.1.12:8554/unicast',
         timeLimit: 60, // time in seconds for each segmented video file
         folder: __dirname,
         name: 'cam1',
     })
     // Starts Recording
     rec.startRecording();
 
     setTimeout (() => {
         console.log('Stopping Recording')
         rec.stopRecording()
         rec = null
     }, 300000)

image capture example

     const Recorder = require('node-rtsp-recorder').Recorder
 
     var rec = new Recorder ({
         url: 'rtsp://192.168.1.12:8554/unicast',
         folder: __dirname,
         name: 'cam1',
         type: 'image',
     })
 
     rec.captureImage (() => {
         console.log('Image Captured')
     })

Hope this helps :)

This library might help rtsp-video-recorder .

In case of any question, suggestion or feature request you may contact me trough the github issue tab

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM