Registry / http-networking / node-rtsp-stream

node-rtsp-stream

JSON →
library0.0.9jsnpmunverified

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-stream
INSTALL
IMPORT
SIG · NODE-RTSP-STREAM
N
node-rtsp-stream
http-networkingjavascriptv0.0.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Stream
const Stream = require('node-rtsp-stream')
import Stream from 'node-rtsp-stream'
This package is CommonJS-only and does not support ES modules directly without a transpiler. The exported symbol is the Stream class constructor.
Stream instance
const myStream = new Stream({...})
const Stream = new Stream({...})
Avoid using the same variable name for the imported class (Stream) and its instance to prevent runtime errors and confusion.

Sets up a Node.js server to convert an RTSP stream into a WebSocket stream for client-side consumption, requiring a pre-installed `ffmpeg`.

const Stream = require('node-rtsp-stream'); const stream = new Stream({ name: 'my-rtsp-stream', streamUrl: 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov', // Replace with your RTSP URL wsPort: 9999, ffmpegOptions: { // Options passed directly to ffmpeg '-stats': '', // Show ffmpeg stats '-r': 30, // Output framerate (important for JSMpeg compatibility) '-vcodec': 'mpeg1video', // Ensure output is MPEG1 video '-f': 'mpegts' // Output format as MPEG Transport Stream } }); console.log(`RTSP stream starting on ws://localhost:${stream.wsPort}`); console.log('Ensure ffmpeg is installed and accessible in your system PATH.'); console.log('A client (e.g., JSMpeg) can connect to this WebSocket port.'); // Basic error handling for the stream process // Note: This package has limited direct error event exposure beyond ffmpeg process exit // More robust error handling might involve monitoring the ffmpeg child process. process.on('SIGINT', () => { console.log('Stopping stream...'); // In a real application, you might want a .stop() method or similar // As this package doesn't expose a direct stop, the process will exit. process.exit(0); });
Debug
Known issues
breakingThis package requires the `ffmpeg` executable to be installed and accessible in the system's PATH. Without `ffmpeg`, the stream will fail to start with a 'spawn ffmpeg ENOENT' error.
fix
Install `ffmpeg` on your operating system and ensure its executable directory is added to your system's PATH environment variable.
affects: >=0.0.1
gotchaRTSP camera framerates must be 15fps or higher for stable MPEG1 encoding, with 25fps recommended. If the source framerate is too low or the codec is unsupported (e.g., H.264), `ffmpeg` errors will occur, preventing video encoding. JSMpeg itself is optimized for specific MPEG1 framerates.
fix
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.
affects: >=0.0.1
deprecatedThe `node-rtsp-stream` package has not been updated since February 2020 and its GitHub repository shows no recent activity, indicating it is effectively abandoned. There are forks, but the main package lacks maintenance, security updates, and modern JavaScript features like native ESM support.
fix
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.
affects: >=0.0.9
gotchaIf the RTSP stream URL requires authentication (username/password), these credentials must be embedded directly into the `streamUrl` for `ffmpeg` to access it, e.g., `rtsp://username:password@ipaddress:port/path`.
fix
Include `username` and `password` in the `streamUrl` as `rtsp://username:password@host:port/path`.
affects: >=0.0.1
Errors
Common errors & fixes
Error: spawn ffmpeg ENOENT
The `ffmpeg` executable is not found in the system's PATH.
fix
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.
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used).
This error often indicates that `ffmpeg` failed to correctly process the input RTSP stream, possibly due to unsupported codecs, too low framerate, or issues with the stream URL itself.
fix
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`.
[rtsp @ 0x...] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
`ffmpeg` is struggling to detect the codec parameters or format of the incoming RTSP stream. This is common with some IP cameras or non-standard stream configurations.
fix
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.
TypeError: Stream is not a constructor (or similar variable collision error)
A common mistake is using the same variable name (`Stream`) for both the imported class and its instance, leading to `TypeError` or unexpected behavior.
fix
Use a different variable name for the stream instance, e.g., `const myStream = new Stream({...})` instead of `const Stream = new Stream({...})`.
'RTSP stream exited with error' when trying to use rtsp via public ip
This often occurs when the `streamUrl` points to a public IP address or a complex network setup, where network firewalls, NAT, or routing issues prevent `ffmpeg` from establishing a stable connection to the RTSP source.
fix
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.
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies
ffmpegrequiredExternal executable required for RTSP decoding and re-encoding to MPEG1. Must be installed globally or available in PATH.
Agent activity
6 hits · last 30 days
node
6
Resources