node-rtsp-stream is a Node.js package designed to convert real-time streaming protocol (RTSP) video feeds into WebSocket streams for consumption by client-side libraries like JSMpeg, enabling HTML5 video playback in browsers. The package, currently at version 0.0.9, was last published in February 2020. It acts as a wrapper around the `ffmpeg` executable, which must be independently installed on the system, to handle the heavy lifting of decoding and re-encoding video. Its primary differentiation lies in its direct integration with JSMpeg for low-latency, canvas-based browser playback, making it suitable for basic live video surveillance or embedded system applications. Due to its age, it primarily supports CommonJS and has not seen active development or major releases in several years, indicating a static or abandoned status.
npm install node-rtsp-streamVerified import paths — ran on the pinned version, not inferred.
Sets up a Node.js server to convert an RTSP stream into a WebSocket stream for client-side consumption, requiring a pre-installed `ffmpeg`.
Install `ffmpeg` on your operating system and ensure its executable directory is added to your system's PATH environment variable.
Configure the RTSP source camera to stream at a recommended framerate (e.g., 25-30fps). You may need to explicitly specify '-vcodec mpeg1video' and other `ffmpegOptions` to ensure compatible output, and potentially add `-strict -1` to allow non-standard framerates if needed.
For new projects, consider alternatives that are actively maintained or provide more direct control over `ffmpeg` processes (e.g., `fluent-ffmpeg`) combined with WebSocket servers, or other purpose-built streaming solutions for Node.js. Evaluate the long-term support implications if using this package.
Include `username` and `password` in the `streamUrl` as `rtsp://username:password@host:port/path`.
Install `ffmpeg` on your operating system and ensure the directory containing `ffmpeg.exe` (Windows) or `ffmpeg` binary (Linux/macOS) is added to your system's PATH environment variable.
Verify the `streamUrl` is correct and accessible. Check if the RTSP stream uses a compatible codec (H.264, etc.) and if `ffmpeg` can transcode it to MPEG1. Ensure the camera's framerate is 15fps or higher. Add explicit `ffmpegOptions` like `-vcodec mpeg1video`, `-f mpegts`, and `-r 30`.
Add `ffmpegOptions` to explicitly define input parameters for `ffmpeg`, such as `'-analyzeduration': '10000000'`, `'-probesize': '10000000'`, and potentially `'-i_codec': 'h264'` if the input is known to be H.264.
Use a different variable name for the stream instance, e.g., `const myStream = new Stream({...})` instead of `const Stream = new Stream({...})`.Ensure that the network configuration allows the Node.js server to access the RTSP stream. This may involve port forwarding, firewall rules, or using a local IP address if the stream is on the same network. Consider adding `'-rtsp_transport': 'tcp'` to `ffmpegOptions` to force TCP for reliability.