如何记录RTSP流

问题描述 投票:1回答:1

我正在使用node-rtsp-stream包和Websocket进行IP摄像机的传输,并且可视化效果很好,现在我想知道如何记录此传输,我不知道该怎么做。

服务器端(NodeJS)中的index.js

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
  })

在客户端

<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>
javascript html node.js rtsp recorder
1个回答
0
投票

您可以使用node-rtsp-recorder库,使用起来很简单。

录制示例

     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)

图像捕捉示例

     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')
     })

希望这会有所帮助:)

© www.soinside.com 2019 - 2024. All rights reserved.