开源一个基于js的RTMP服务端

其实是2个,一个基于fibjs,一个基于nodejs
两个版本大部分是一样的,只是在数据处理方面有差异。

fibjs版本:https://github.com/illuspas/NodeMediaServer
fibjs没有回调一说,同步的流程写起来相当舒服。

nodejs版:https://github.com/illuspas/Node-Media-Server
nodejs的数据是on(‘data’)回调回来的,解析rtmp包很费劲,需要根据包头一步一步分析出需要的包大小。为此写了个QueueBuffer类,请求的数据大小足够即返回,不够就回压再等待数据下次继续解析。

目前只支持了H264+AAC,支持多路发布和播放。
fibjs版目前在大并发的时候会阻塞发布端,写得有点问题,空了再改改。
没有缓冲关键帧,播放的启动时间可能会等下一个关键帧来了才开始

此项目仅为空闲时写着玩的,参照了很多别人的代码,并不会长期维护。如果你感兴趣,欢迎fork。

原创文章,转载请注明: 转载自贝壳博客

本文链接地址: 开源一个基于js的RTMP服务端

1 评论

  1. I have downloaded your great project (from https://github.com/illuspas/Node-Media-Server) and am trying to use it with my IP-camera and web page. I want to display the cam’s RTSP-stream on my html-page.

    When I send a GET request to the node media server, I get ERR_EMPTY_RESPONSE back. I also have this terminal output from the node server: “2018-12-26 16:41:21 28416 [INFO] [websocket-flv play] Stream not found. id=8NZ5ZWKE streamPath=/live/uterum”

    I have tried to copy your code example (from github) but obviously I am missing something?

    I have written a question with more details regarding this on Stack Overflow: https://stackoverflow.com/questions/53934702/re-stream-rtsp-from-ip-cam-with-node-media-server-to-http-ws-and-display-it-with

    Thanks for your project anyway!

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据