npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rtsp2ws

v0.0.5

Published

rtsp转换为websocket

Readme

RTSP TO WS

RTSP视频流解析为WebSocket形式(转换后视频格式为MPEG1),在前端使用支持WebSocket 的播放器JSMpeg即可实现web页面播放rtsp视频流

使用方式一(npm引入)

const Rtsp2WsServer = require("rtsp2ws");

new Rtsp2WsServer({ffmpeg: "D:\\pgs\\ffmpeg-master-latest-win64-gpl\\bin\\ffmpeg.exe"}).listen();

使用方式二(未打包为npm包的情况下)

const Rtsp2WsServer = require("./src/utils/Rtsp2WsServer");

const rtsp2ws = new Rtsp2WsServer({ffmpeg: "D:\\pgs\\ffmpeg-master-latest-win64-gpl\\bin\\ffmpeg.exe"});
rtsp2ws.listen();

使用如上代码则启动了一个websocket服务,在前端构造对应的websocket连接地址放入播放器url中即可播放

详细介绍

Rtsp2WsServer的构造函数默认参数如下

{
  "port": 9999,
  "path": "/proxy",
  "ffmpeg": "ffmpeg",
  "audio": true,
  "freeTime": 60,
  "checkTime": 10,
  "transportType": "tcp"
}

| 属性 | 默认值 | 描述 | 备注 | |---------------|--------|-------------------|-----------------------| | port | 9999 | websocket服务端口 | --- | | path | /proxy | 类似contextPath | --- | | ffmpeg | ffmpeg | ffmpeg安装位置 | 如ffmpeg存在于环境变量中,可直接使用 | | audio | true | 是否播放声音 | 目前未做此功能,但可以通过url参数实现 | | freeTime | 60 | 多长时间后将ffmpeg视为闲置 | 闲置的ffmpeg解析流将被中止 | | checkTime | 10 | 检查ffmpeg进程是否闲置的间隔 | --- | | transportType | tcp | rtsp流传输协议 | --- |

按照如上默认的参数配置,启动websocket服务后,ws的连接为 ws://localhost:9999/proxy,具体的连接url按自己的配置设置

播放器url

同时,因为每个页面需要代理的url不同,所以将需要代理的url通过ws连接统一传递

示例: 如你有一个rtsp视频流地址如下: rtsp://localhost:8554/video,使用如下方式拼接

const wsUrl = "ws://localhost:9999/proxy"
const rtspUrl = "rtsp://localhost:8554/video"

function concatLink() {
  return `${wsUrl}?url=${btoa(rtspUrl)}`
}

同时url连接中还可以写入ffmpeg解析视频流的参数,如:是否播放声音(-an),视频质量(-q)等内容,详情见ffmpeg配置项