notedit / rtmp-to-webrtc

rtmp to webrtc
214 stars 61 forks source link

部署失败 #3

Closed hxhlb closed 5 years ago

hxhlb commented 5 years ago

技术能力不够, 请求帮助. 在ubuntu18.04上, node server.js 直接报错, TypeError: NodeMediaServer is not a constructor 但是我在本目录下新建一个单独的文件test.js, 确认NodeMediaServer是没问题的, 代码就是复制的server.js中的, 除了回调没加, 其他代码都一样. node版本10.14.2 LTS版.

在ubuntu16.04上可以运行成功, 但是看不到图像, 然后很快就整个挂掉了, 日志:

 dev % node server.js
[0x7f338f096740][1545803228.560][LOG]>DTLSConnection::Initialize()
[0x7f338f096740][1545803228.560][LOG]>DTLSConnection::GenerateCertificate()
[0x7f338f096740][1545803228.565][LOG]<DTLSConnection::GenerateCertificate()
[0x7f338f096740][1545803228.565][LOG]<DTLSConnection::Initialize(5)
[0x7f338f096740][1545803228.602][LOG]>RTPBundleTransport::Init()
[0x7f338f096740][1545803228.602][LOG]-RTPBundleTransport::Init() | Got port [56748]
[0x7f338b81d700][1545803228.602][LOG]-RTPBundleTransport::run() | thread [31835,0x3d655a0]
[0x7f338b81d700][1545803228.602][LOG]>RTPBundleTransport::Run() | [0x3d655a0]
[0x7f338f096740][1545803228.602][LOG]-Created thread [0x3d655c0]
[0x7f338f096740][1545803228.602][LOG]<RTPBundleTransport::Init()
[0x7f338f096740][1545803228.603][LOG]-EnableDebug [1]
[0x7f338f096740][1545803228.603][LOG]-EnableUltraDebug [1]
Example app listening on port 4001!

Open http://localhost:4001/
2018-12-26 13:47:08 [INFO] Node Media Rtmp Server started on port: 1935
2018-12-26 13:49:06 [INFO] [rtmp connect] id=OZ4MQKKJ ip=127.0.0.1 app=live args={"app":"live","type":"nonprivate","tcUrl":"rtmp://127.0.0.1/live"}
2018-12-26 13:49:06 [INFO] [rtmp publish] New stream. id=OZ4MQKKJ streamPath=/live/live streamId=1
2018-12-26 13:49:06 [INFO] [rtmp publish] Handle video. id=OZ4MQKKJ streamPath=/live/live frame_type=1 codec_id=7 codec_name=H264 640x480
[NodeEvent on postPublish] id=OZ4MQKKJ StreamPath=/live/live args={"ac":0,"vc":7}
request body { offer: 'v=0\r\no=- 5483419964224663026 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 123 127 122 125 107 108 109 124\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:fbFL\r\na=ice-pwd:9FX+rFsPjAO3VGhvlxe/4Mai\r\na=ice-options:trickle\r\na=fingerprint:sha-256 1B:F9:D4:84:B5:9A:03:98:F5:7D:2F:48:F7:FD:59:6B:26:3C:39:65:EE:93:A3:08:B5:20:19:20:FF:5E:FA:C9\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:10 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=recvonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 H264/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:123 rtx/90000\r\na=fmtp:123 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 red/90000\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 ulpfec/90000\r\n' }

<--- Last few GCs --->

[31835:0x3c6c060]   218165 ms: Mark-sweep 1316.3 (1474.5) -> 1316.2 (1475.0) MB, 1576.3 / 8.2 ms  allocation failure GC in old space requested
[31835:0x3c6c060]   219268 ms: Mark-sweep 1316.2 (1475.0) -> 1316.2 (1444.0) MB, 1103.2 / 3.7 ms  last resort GC in old space requested
[31835:0x3c6c060]   220686 ms: Mark-sweep 1316.2 (1444.0) -> 1316.2 (1444.0) MB, 1417.7 / 3.8 ms  last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x13676b4a58b9 <JSObject>
    1: push(this=0x102b1ee1c3f1 <JSArray[933158]>)
    2: /* anonymous */ [internal/process/promises.js:~21] [pc=0x3a3d0dc3fb92](this=0x38b1c09cf9 <process map = 0x195d0440a341>,event=0,promise=0x34bb1c5fd501 <Promise map = 0x195d04404721>,reason=0x1d9662022d1 <undefined>)
    6: reject(this=0x13676b497959 <JSFunction Promise (sfi = 0x1d96622b9d1)>,0x1d9662022d1 <undefined>)
    7: arguments ada...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x8cce9c [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewUninitializedFixedArray(int) [node]
 6: 0xd818bf [node]
 7: 0xd959f5 [node]
 8: v8::internal::JSObject::AddDataElement(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow) [node]
 9: v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow, v8::internal::Object::StoreFromKeyed) [node]
10: v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::LanguageMode, v8::internal::Object::StoreFromKeyed) [node]
11: v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x3a3d0da842fd
zsh: abort (core dumped)  node server.js
 dev %

请求帮助. 我看您这示例网站挺好的, 为什么我就不行呢?

notedit commented 5 years ago

TypeError: NodeMediaServer is not a constructor

这个是因为 node-media-server 版本不对, 请使用我代码里的版本 用 npm install 来安装

其他的错误, 看不出是哪里的问题

hxhlb commented 5 years ago

是使用npm install来安装的, 我确认了一下, package.json中有写版本号, 但是单独执行显示的是最新版本, 很纠结. 不知您可否告知您的服务器系统版本, npm版本, 我去搭建一套环境试试.

hxhlb commented 5 years ago

事实证明是因为我是后来更新了nodejs到lts版导致的node-media-server的异常. 现在NodeMediaServer没有问题了, 但是还是崩溃. 我在看看是什么参数在搞怪.

notedit commented 5 years ago

服务器是 ubuntu 16.04 node v8.9.1 npm 5.8.0

开发环境是 macOS 10.13

另外如果你要部署在服务器上的话 https://github.com/notedit/rtmp-to-webrtc/blob/master/server.js#L10

这里的ip要填写你服务器的公网ip

应该不是node版本的问题, 我本地开发都用最新的node

notedit commented 5 years ago

另外可以说一下你的需求 看是否能帮助到

hxhlb commented 5 years ago

感谢, 我就是因为rtmp的延迟还挺高, 并且越播延迟越大, 看到你这个方案想尝试一下. 最近想看看什么方式能够解决这种延迟, 正在广泛的收集资料.

notedit commented 5 years ago

webrtc可以用来做直播的 我们内部已经研发了 但还没产品化