phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.34k stars 1.43k forks source link

Problems replicating example. #166

Open ad84 opened 7 years ago

ad84 commented 7 years ago

Ive been trying to replicate the example in the readme; when I open the view-stream.html the websocket-relay ends (after connecting ok to the stream?) with:

adam@adam-pc:~/jsmpeg$ node websocket-relay.js yourpassword
Listening for incomming MPEG-TS Stream on http://127.0.0.1:8081/<secret>
Awaiting WebSocket connections on ws://127.0.0.1:8082/
Stream Connected: ::ffff:127.0.0.1:40832
/home/adam/jsmpeg/websocket-relay.js:31
                socket.upgradeReq.socket.remoteAddress,
                                 ^

TypeError: Cannot read property 'socket' of undefined
    at WebSocketServer.<anonymous> (/home/adam/jsmpeg/websocket-relay.js:31:20)
    at emitTwo (events.js:106:13)
    at WebSocketServer.emit (events.js:191:7)
    at handleUpgrade (/home/adam/node_modules/ws/lib/WebSocketServer.js:88:16)
    at WebSocketServer.completeUpgrade (/home/adam/node_modules/ws/lib/WebSocketServer.js:270:5)
    at WebSocketServer.handleUpgrade (/home/adam/node_modules/ws/lib/WebSocketServer.js:197:10)
    at Server.WebSocketServer._ultron.on (/home/adam/node_modules/ws/lib/WebSocketServer.js:87:14)
    at emitThree (events.js:116:13)
    at Server.emit (events.js:194:7)
    at onParserExecuteCommon (_http_server.js:409:14)
adam@adam-pc:~/jsmpeg$ node websocket-relay.js yourpassword
Listening for incomming MPEG-TS Stream on http://127.0.0.1:8081/<secret>
Awaiting WebSocket connections on ws://127.0.0.1:8082/
/home/adam/jsmpeg/websocket-relay.js:31
                socket.upgradeReq.socket.remoteAddress,  

ffmpeg also ends with:

  frame=  739 fps= 30 q=4.5 size=    2726kB time=00:00:24.56 bitrate= 909.1kbits/s dup=587 drop=0 
    speedframe=  754 fps= 30 q=5.9 size=    2779kB time=00:00:25.06 bitrate= 908.2kbits/s dup=599 
    drop=0 speedframe=  768 fps= 30 q=6.1 size=    2821kB time=00:00:25.53 bitrate= 905.2kbits/s 
    dup=610 drop=0 speedframe=  783 fps= 30 q=5.2 size=    2889kB time=00:00:26.03 bitrate= 
    909.0kbits/s dup=622 drop=0 speedframe=  802 fps= 31 q=4.8 size=    2943kB time=00:00:26.66 
    bitrate= 904.1kbits/s dup=637 drop=0 speedav_interleaved_write_frame(): Broken pipe
        Last message repeated 3 times
    Error writing trailer of http://127.0.0.1:8081/yourpassword/640/480/: Broken pipe
    frame=  811 fps= 31 q=4.4 Lsize=    2977kB time=00:00:26.96 bitrate= 904.3kbits/s dup=644 drop=0 
    speed=1.01x    
    video:2977kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 
    0.000000%
    Conversion failed!'

Its probably incorrect usage on my part; any help would be greatly appreciated.

phoboslab commented 7 years ago

I believe this happens with old nodejs versions. Try updating.

ad84 commented 7 years ago

The attempt above is using node js 6.x, however I did wonder if this was the problem so I installed 7 in a virtual box lubuntu (fresh install) and received the same error. I can replicate this again if it helps.

phoboslab commented 7 years ago

What's your ffmpeg command?

Nibbler999 commented 7 years ago

You should install ws@2 to use the relay, as it needs an update for ws 3 compatibility.

ad84 commented 7 years ago

It was the ws version, removed version 3 and installed 2 as suggested by @Nibbler999 and it all works well. Thanks for the help!