Giter VIP home page Giter VIP logo

node-rtsp-rtmp-server's Introduction

RTSP, RTMP, and HTTP server in Node.js

  • Supports RTSP, RTMP/RTMPE/RTMPT/RTMPTE, and HTTP.
  • Supports only H.264 video and AAC audio (AAC-LC, HE-AAC v1/v2).

Installation without Docker

$ git clone https://github.com/iizukanao/node-rtsp-rtmp-server.git
$ cd node-rtsp-rtmp-server
$ npm install -d

Also, install CoffeeScript 1.x or 2.x.

Configuration

Edit config.coffee.

Starting the server

$ cd node-rtsp-rtmp-server
$ sudo coffee server.coffee

or use Node.js directly:

$ cd node-rtsp-rtmp-server
$ coffee -c *.coffee
$ sudo node server.js

If both serverPort and rtmpServerPort are >= 1024 in config.coffee, sudo is not needed.

Docker Deploy Method

If you would prefer building and executing this code in a docker container, you can do so by first building the container and then running it.

$  make build
$  make console

You may also want to use just make run to run the container as a daemon. If you fiddle with the ports, you'll need to update the values in the Makefile as well to expose the desired ports to your system.

Serving MP4 files as recorded streams

MP4 files in file directory will be accessible at either:

  • rtsp://localhost:80/file/FILENAME
  • rtmp://localhost/file/mp4:FILENAME

For example, file/video.mp4 is available at rtmp://localhost/file/mp4:video.mp4

Publishing live streams

From FFmpeg

If you have an MP4 file with H.264 video and AAC audio:

$ ffmpeg -re -i input.mp4 -c:v copy -c:a copy -f flv rtmp://localhost/live/STREAM_NAME

Or if you have an MP4 file that is encoded in other audio/video format:

$ ffmpeg -re -i input.mp4 -c:v libx264 -preset fast -c:a libfdk_aac -ab 128k -ar 44100 -f flv rtmp://localhost/live/STREAM_NAME

Replace input.mp4 with live audio/video sources.

From RTSP client

You can publish streams from RTSP client such as FFmpeg.

$ ffmpeg -re -i input.mp4 -c:v libx264 -preset fast -c:a libfdk_aac -ab 128k -ar 44100 -f rtsp rtsp://localhost:80/live/STREAM_NAME

Or you can publish it over TCP instead of UDP, by specifying -rtsp_transport tcp option. TCP is favorable if you publish large data from FFmpeg.

$ ffmpeg -re -i input.mp4 -c:v libx264 -preset fast -c:a libfdk_aac -ab 128k -ar 44100 -f rtsp -rtsp_transport tcp rtsp://localhost:80/live/STREAM_NAME

From GStreamer

For an MP4 file with H.264 video and AAC audio:

$ gst-launch-0.10 filesrc location=input.mp4 ! qtdemux name=demux ! \
    flvmux name=mux streamable=true ! queue ! \
    rtmpsink location='rtmp://localhost/live/STREAM_NAME' demux. ! \
    multiqueue name=mq ! h264parse ! mux. demux. ! mq. mq. ! aacparse ! mux.

Replace input.mp4 with live audio/video sources.

For an RTSP source (at rtsp://192.168.1.1:5000/video1 in this example):

$ gst-launch-0.10 rtspsrc location=rtsp://192.168.1.1:5000/video1 ! decodebin ! \
    x264enc bitrate=256 tune=zerolatency  ! h264parse ! flvmux name=mux streamable=true ! \
    queue ! rtmpsink location='rtmp://localhost/live/STREAM_NAME' 

Accessing the live stream

Via RTSP

RTSP stream is for VLC media player or Android's VideoView.

RTSP URL: rtsp://localhost:80/live/STREAM_NAME

Note that the RTSP server runs on port 80 by default.

Via RTMP

RTMP stream is also available.

RTMP URL: rtmp://localhost/live/STREAM_NAME

If you have rtmpdump installed, you can record the video with:

$ rtmpdump -v -r rtmp://localhost/live/STREAM_NAME -o dump.flv

node-rtsp-rtmp-server's People

Contributors

chad3814 avatar iizukanao avatar jandrieu avatar siyuyue avatar skitisu avatar thenotary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-rtsp-rtmp-server's Issues

publish rtmp stream from Flash or Flash Media Encoder

I tried to use the server by publishing the stream from flash swf and also from Flash Media Encoder . In both I got an error and server crashed .

new RTMPSession
Waiting for complete C0+C1
client type: 3
Waiting for complete C2+RTMPMessage
[rtmp] handshake success, buf.length=1936

/root/node-rtsp-rtmp-server/server.coffee:741
throw err;
^
Error: Unknown AMF0 data type: 49
at parseAMF0Data (/root/node-rtsp-rtmp-server/rtmp.coffee:292:15)
at parseAMF0CommandMessage (/root/node-rtsp-rtmp-server/rtmp.coffee:247:14)
at RTMPSession.handleData (/root/node-rtsp-rtmp-server/rtmp.coffee:1369:28)
at Socket. (/root/node-rtsp-rtmp-server/rtmp.coffee:1446:23)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (stream_readable.js:746:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:528:21)

Publish on NPM

Hi, is it possible to publish this repository to the npm. It would be easier to use. Or make a version number in the package.json, because now I can't include this repository on my node project.

Error: No version provided

request invalid app name live/test1

Hello , when I try to insert the stream name , the rtmp server node goes into infinite loop ,
i use OBS
how do I fix ?

error:
unkown message format, assuming format 1
request invalid app name live/test1

other question, you can assign a streamkey in this project ?
thanks for the great job

OBS Studio fails to stream to the server properly, OBS works fine

this may be a strange issue, but since the team over at OBS are pushing the issue to other projects, maybe you could help me figure out why OBS streams to the server fine and OBS Studio/multiplatform fails.

OBS Studio seems to deliver the first frame of the stream fine, but then flowplayer buffers forever instead of receiving the next frame. here is the thread i put out on the OBS forums: https://obsproject.com/forum/threads/stream-width-correct-in-obs-not-obs-multiplatform.40703/

you seem to know enough about this protocol to be able to offer some insight on this issue, but if this is too irrelevant to the project then feel free to close it.

RTMP:handshake unknown message format from OBS

Hey there,

when connecting from Open Broadcaster Studio (mac 0.14.1) to rtmp://localhost/live and a streaky the OBS just answers:

[rtmp:handshake] warning: unknown message format, assuming format 1

How to connect to the server through OBS?
Thanks!

Remote RTMP server

This is more of a feature request - would it be possible to use this server only for RTMPT and use a remote RTMP server? I have tried modifying the server to allow for this, but I am having trouble with getting past the stream registration part, since it is on a remote server and not running through the accompanying rtmp server stack. Would you be at all interested in supporting this, either with a fork or a patch?

server crashed when client play stream without audio via rtsp protocal

2015-05-23 19:21:19.519 [rtmp] server started on port 1935
2015-05-23 19:21:19.573 [rtsp/http] server started on port 80
2015-05-23 19:22:27.546 [rtsp/http] client c1 connected
[rtsp/http: 1 clients]
c1: session=38186821 addr=10.253.66.198 port=58072 type=publish-udp
2015-05-23 19:22:27.710 [rtsp] client c1 started uploading stream stream1
2015-05-23 19:24:45.330 [rtsp/http] client c2 connected
/home/pi/sources/node-rtsp-rtmp-server/server.js:41
throw err;
^
Error: null channels audio is not supported
at Object.api.getChannelConfiguration (/home/pi/sources/node-rtsp-rtmp-server/aac.js:317:17)
at Object.api.createAudioSpecificConfig (/home/pi/sources/node-rtsp-rtmp-server/aac.js:575:36)
at /home/pi/sources/node-rtsp-rtmp-server/rtsp.js:1444:60
at RTSPServer.livePathConsumer (/home/pi/sources/node-rtsp-rtmp-server/server.js:24:14)
at RTSPServer.consumePathname (/home/pi/sources/node-rtsp-rtmp-server/rtsp.js:1264:21)
at RTSPServer.respondDescribe (/home/pi/sources/node-rtsp-rtmp-server/rtsp.js:1408:19)
at RTSPServer.respond (/home/pi/sources/node-rtsp-rtmp-server/rtsp.js:1916:21)
at RTSPServer.handleOnData (/home/pi/sources/node-rtsp-rtmp-server/rtsp.js:1019:19)
at Socket. (/home/pi/sources/node-rtsp-rtmp-server/rtsp.js:496:28)
at Socket.emit (events.js:107:17)

Codec // h264 in RTSP, but avc1 in RTMP

Hello,

I have been analysing the output of the RTMP stream, and it appears that the signature of the video codec is no longer h264, but acv1. I managed to see that through VLC in media informations.

Hence, when I try to play the RTMP stream in flash I get an error message:
[12:45:53.773] <<<< VTVideoDecoderSelection >>>> VTSelectAndCreateVideoDecoderInstanceInternal: no video decoder accepted for 'avc1'

And the framerate compared to the original stream is kind of shitty then ... about 10 fps in opposition of the 22fps provided by the live IP cam feed.

When I open both RTSP and RTMP stream in VLC everything is fine, so obviously the video codec used by the node app is not manageable by flash.

Any idea?

FFMpeg // RTM missed x packets

Hello there,

I am trying to make all that work. The server seems to work fine but when I feed a RTSP stream coming from my IP cam I seem to get a LOST of "RTM: missed x packets".
Here is a screenshot:
screen shot 2015-07-01 at 12 02 32

Any idea what would cause this? I assume it is a ffmpeg issue and not a node.js issue ...
Thanks a lot !

Hi, Does this error mean something?

Hi,
Thanks for your hard work. This tool helps me a lot.
But when I use it relay rtsp stream , I encounter an error.
Although I encounter this error, I can watch video with VLC normally. So, I want to know if this error means something?
Thanks !
1

An example of usage

Hey,

I'm pretty excited about his project. I'm trying to get the server to work. Do you have an example of how you use it?

I'm looking to use this to host network rtsp video feeds. I understand currently it is supposed to get audio/video over a unix domain socket but I'm looking to expand it to TCP/UDP network sockets.

Not implemented: nal_unit_type=24

Hi

95% of the time everything works perfect, great job!
Except with some videos I'm getting the following error:

Error: Not implemented: nal_unit_type=24
    at Object.api.readH264Payload (rtp.js:486:19)
    at Object.api.parseH264Packet (rtp.js:465:25)
    at RTPParser.feedUnorderedH264Buffer (rtp.js:64:20)
    at RTSPServer.onUploadVideoData (rtsp.js:1924:31)
    at Socket.<anonymous> (rtsp.js:497:26)
    at Socket.emit (events.js:98:17)
    at UDP.onMessage (dgram.js:441:8)

I already tried to drop the frames, but that results in an other error.
If you want a video that produces the error just let me know and I will send you one.

Thanks!

Socket error (c6): Error: write EPIPE

Getting this weird error whenever a client tries to connect via http.
This code is running on a ubuntu version having node 4.4.5 version. Here is the full output:

root@ubuntu-512mb-nyc3-01:~/node-rtsp-rtmp-server# sudo nodejs server.js 2016-06-15 12:54:43.254 attachRecordedDir: dir=file app=file 2016-06-15 12:54:43.299 [rtmp] server started on port 1935 2016-06-15 12:54:43.301 [rtsp/http/rtmpt] server started on port 8080 2016-06-15 12:54:49.620 [rtsp/http/rtmpt:client=c1] connected 2016-06-15 12:54:49.974 [rtsp/http/rtmpt:client=c2] connected 2016-06-15 12:54:50.539 Socket error (c1): Error: write EPIPE 2016-06-15 12:54:50.540 [rtsp/http/rtmpt:client=c1] disconnected

coffee server.coffee failed?

What "Edit config.coffee" is for?
And I have done follow your steps, but it still failed, the error is as follow:

D:\node-rtsp-rtmp-server-master>coffee server.coffee
2016-01-08 10:09:45.328 attachRecordedDir: dir=file app=file
D:\node-rtsp-rtmp-server-master\server.coffee:46
throw err;
^

Error: listen EACCES /tmp/node_rtsp_rtmp_videoControl
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at Server._listen2 (net.js:1225:19)
at listen (net.js:1274:10)
at Server.listen (net.js:1364:5)
at CustomReceiver.startUnix (D:\node-rtsp-rtmp-server-master\custom_receiver.coffee:91:27)
at CustomReceiver.start (D:\node-rtsp-rtmp-server-master\custom_receiver.coffee:82:8)
at StreamServer.start (D:\node-rtsp-rtmp-server-master\stream_server.coffee:216:21)
at Object. (D:\node-rtsp-rtmp-server-master\server.coffee:34:14)
at Object. (D:\node-rtsp-rtmp-server-master\server.coffee:1:1)
at Module._compile (module.js:435:26)
at Object.exports.run (D:\Program Files\nodejs\node_modules\coffee-script\lib\coffee-script\coffee-script.js:134:23)
at compileScript (D:\Program Files\nodejs\node_modules\coffee-script\lib\coffee-script\command.js:224:29)
at compilePath (D:\Program Files\nodejs\node_modules\coffee-script\lib\coffee-script\command.js:174:14)
at Object.exports.run (D:\Program Files\nodejs\node_modules\coffee-script\lib\coffee-script\command.js:98:20)
at Object. (D:\Program Files\nodejs\node_modules\coffee-script\bin\coffee:7:41)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3

Disconnect right after connecting

Node server.js output:

2016-06-13 10:03:13.879 attachRecordedDir: dir=file app=file
2016-06-13 10:03:13.893 [rtmp] server started on port 1935
2016-06-13 10:03:13.894 [rtsp/http/rtmpt] server started on port 80
2016-06-13 10:03:17.651 [rtmp:client=1oZ9Ns6Y] connected
[rtmp: 1 sessions]
 1oZ9Ns6Y: addr=127.0.0.1 port=5741
2016-06-13 10:03:17.658 [rtmp:handshake] warning: unknown message format, assuming format 1
2016-06-13 10:03:17.665 [rtmp:receive] unknown (not implemented) AMF command: _checkbw
2016-06-13 10:03:17.668 [rtmp] publish: stream=live/helloworld publishingType=live
2016-06-13 10:03:18.104 [rtmp:client=1oZ9Ns6Y] received EOS for stream: live/helloworld
2016-06-13 10:03:18.106 [rtmp] FCUnpublish: helloworld
2016-06-13 10:03:18.108 [rtmp:client=1oZ9Ns6Y] socket error: Error: read ECONNRESET
2016-06-13 10:03:18.108 [rtmp:client=1oZ9Ns6Y] disconnected
[rtmp: 0 sessions]

FFmpeg output:

$ ffmpeg.d1c8368.exe -i big_buck_bunny.mp4 -c:v copy -c:a copy -f flv rtmp://localhost/live/helloworld
ffmpeg version N-75794-gd1c8368 Copyright (c) 2000-2015 the FFmpeg develope
rs                                                                         
  built with gcc 5.2.0 (GCC)                                               
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enab
le-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnu
tls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --en
able-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enab
le-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable
-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable
-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enabl
e-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --ena
ble-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --e
nable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zli
b                                                                          
  libavutil      55.  2.100 / 55.  2.100                                   
  libavcodec     57.  4.100 / 57.  4.100                                   
  libavformat    57.  3.100 / 57.  3.100                                   
  libavdevice    57.  0.100 / 57.  0.100                                   
  libavfilter     6. 10.100 /  6. 10.100                                   
  libswscale      4.  0.100 /  4.  0.100                                   
  libswresample   2.  0.100 /  2.  0.100                                   
  libpostproc    54.  0.100 / 54.  0.100                                   
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big_buck_bunny.mp4':              
  Metadata:                                                                
    major_brand     : mp42                                                 
    minor_version   : 1                                                    
    compatible_brands: mp42avc1                                            
    creation_time   : 2010-02-09 01:55:39                                  
  Duration: 00:01:00.10, start: 0.000000, bitrate: 733 kb/s                
    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo
, fltp, 65 kb/s (default)                                                  
    Metadata:                                                              
      creation_time   : 2010-02-09 01:55:39                                
      handler_name    : Apple Sound Media Handler                          
    Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661
), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 612 kb/s, 23.96 fps, 24
 tbr, 600 tbn, 1200 tbc (default)                                          
    Metadata:                                                              
      creation_time   : 2010-02-09 01:55:39                                
      handler_name    : Apple Video Media Handler                          
    Stream #0:2(eng): Data: none (rtp  / 0x20707472), 45 kb/s              
    Metadata:                                                              
      creation_time   : 2010-02-09 01:55:39                                
      handler_name    : hint media handler                                 
    Stream #0:3(eng): Data: none (rtp  / 0x20707472), 5 kb/s               
    Metadata:                                                              
      creation_time   : 2010-02-09 01:55:39                                
      handler_name    : hint media handler                                 
HandShake: client signature does not match!                                
[flv @ 00dff3a0] Codec for stream 0 does not use global headers but contain
er format requires global headers                                          
[flv @ 00dff3a0] Codec for stream 1 does not use global headers but contain
er format requires global headers                                          
Output #0, flv, to 'rtmp://localhost/live/helloworld':                    
  Metadata:                                                                
    major_brand     : mp42                                                 
    minor_version   : 1                                                    
    compatible_brands: mp42avc1                                            
    encoder         : Lavf57.3.100                                         
    Stream #0:0(eng): Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 640x360
, q=2-31, 612 kb/s, 23.96 fps, 24 tbr, 1k tbn, 600 tbc (default)           
    Metadata:                                                              
      creation_time   : 2010-02-09 01:55:39                                
      handler_name    : Apple Video Media Handler                          
    Stream #0:1(eng): Audio: aac ([10][0][0][0] / 0x000A), 22050 Hz, stereo
, 65 kb/s (default)                                                        
    Metadata:                                                              
      creation_time   : 2010-02-09 01:55:39                                
      handler_name    : Apple Sound Media Handler                          
Stream mapping:                                                            
  Stream #0:1 -> #0:0 (copy)                                               
  Stream #0:0 -> #0:1 (copy)                                               
Press [q] to stop, [?] for help                                            
[flv @ 00dff3a0] Failed to update header with correct duration.            
[flv @ 00dff3a0] Failed to update header with correct filesize.            
frame= 1440 fps=0.0 q=-1.0 Lsize=    5019kB time=00:01:00.14 bitrate= 683.6
kbits/s                                                                    
video:4491kB audio:478kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 1.008274%                                                 

End of stream?

Hi

When i'm streaming the server detects the end of a stream, but he doesn't send this to the clients who are watching. This is a problem for most programs, for example while capturing with OpenCV or FFmpeg the program will be waiting forever for the next frame.

Is this a feature or a bug?

Greetings
Jarno

Error: Unknown AMF0 data type: 108 when rtmp client stream

2016-03-15 23:57:33.649 [rtmp] server started on port 1935
2016-03-15 23:57:33.650 [rtsp/http/rtmpt] server started on port 3000

2016-03-15 23:57:45.300 [rtmp:client=sjXr0K4l] connected
[rtmp: 1 sessions]
sjXr0K4l: addr=192.168.1.103 port=50516
2016-03-15 23:57:45.321 [rtmp:handshake] warning: unknown message format, assuming format 1
2016-03-15 23:57:45.368 [rtmp:receive] unknown (not implemented) AMF data: FCPublish
2016-03-15 23:57:45.368 [rtmp:receive] unknown (not implemented) AMF data: releaseStream
2016-03-15 23:57:45.378 [rtmp] publish: stream=live/myStream publishingType=live
/Users/nvcken/think/node-rtsp-rtmp-server/server.js:47
throw err;
^

Error: Unknown AMF0 data type: 108
at parseAMF0Data (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:356:13)
at parseAMF0StrictArray (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:212:16)
at parseAMF0Data (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:341:16)
at parseAMF0ECMAArray (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:231:16)
at parseAMF0Data (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:310:16)
at parseAMF0StrictArray (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:212:16)
at parseAMF0Data (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:341:16)
at parseAMF0ECMAArray (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:231:16)
at parseAMF0Data (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:310:16)
at parseAMF0DataMessage (/Users/nvcken/think/node-rtsp-rtmp-server/rtmp.js:249:16)

communicating with the rtmp server

i have a project written using MonaServer and i'd like to rewrite it in node.js using this rtmp module, but i'm not sure how to communicate with the rtmp server to do things like client authentication (using url parameters, which also don't seem to be supported in this project) and linking web clients to their corresponding rtmp client.

my assumption was i could just require the server in my node.js main file, but it's a synchronous call and the rtmp server just blocks the rest of the application from running, so i'm at a loss. if the functionality is already there, can you point me in the right direction?

Authentication

Thank you for the great applications.
I was just wondering the easiest way to authenticate node-rtsp-rtmp-server.
Sincerely

Error right after opening stream with VLC

Windows 7.

$ node server.js
2016-06-14 11:20:17.366 attachRecordedDir: dir=file app=file
2016-06-14 11:20:17.379 [rtmp] server started on port 8080
2016-06-14 11:20:17.380 [rtsp/http/rtmpt] server started on port 3000
2016-06-14 11:20:24.099 [rtsp/http/rtmpt:client=c1] connected
2016-06-14 11:20:24.111 [rtsp/http/rtmpt:client=c2] connected
2016-06-14 11:20:26.386 [http] Requested file not found: C:\Users\User\node-rtsp-rtmp-server/public/favicon.ico
2016-06-14 11:20:42.702 [rtsp/http/rtmpt:client=c2] disconnected
[rtsp/http: 1 clients]
 c1: session=77152424 addr=127.0.0.1 port=2104
2016-06-14 11:21:11.832 [rtsp/http/rtmpt:client=c3] connected
2016-06-14 11:21:11.971 [mp4] warning: skipping unknown (not implemented) box type: tref (0x74726566)
2016-06-14 11:21:11.975 [mp4] warning: skipping unknown (not implemented) box type: hmhd (0x686d6864)
2016-06-14 11:21:11.977 [mp4] warning: skipping unknown (not implemented) box type: name (0x6e616d65)
2016-06-14 11:21:11.978 [mp4] warning: skipping unknown (not implemented) box type: hnti (0x686e7469)
2016-06-14 11:21:11.979 [mp4] warning: skipping unknown (not implemented) box type: hinf (0x68696e66)
2016-06-14 11:21:11.981 [mp4] warning: skipping unknown (not implemented) box type: tref (0x74726566)
2016-06-14 11:21:11.987 [mp4] warning: skipping unknown (not implemented) box type: hmhd (0x686d6864)
2016-06-14 11:21:11.988 [mp4] warning: skipping unknown (not implemented) box type: name (0x6e616d65)
2016-06-14 11:21:11.989 [mp4] warning: skipping unknown (not implemented) box type: hnti (0x686e7469)
2016-06-14 11:21:11.996 [mp4] warning: skipping unknown (not implemented) box type: hinf (0x68696e66)
2016-06-14 11:21:11.998 [mp4] warning: skipping unknown (not implemented) box type: hnti (0x686e7469)
C:\Users\User\node-rtsp-rtmp-server\server.js:47
    throw err;
    ^

TypeError: Cannot read property 'sequenceParameterSets' of null
    at MP4File.getSPS (C:\Users\User\node-rtsp-rtmp-server\mp4.js:174:21)
    at Function.MP4Stream.create (C:\Users\User\node-rtsp-rtmp-server\avstreams.js:310:37)
    at Object.api.get (C:\Users\User\node-rtsp-rtmp-server\avstreams.js:488:32)
    at C:\Users\User\node-rtsp-rtmp-server\rtsp.js:1502:32
    at RTSPServer.livePathConsumer (C:\Users\User\node-rtsp-rtmp-server\server.js:26:14)
    at RTSPServer.consumePathname (C:\Users\User\node-rtsp-rtmp-server\rtsp.js:1299:21)
    at RTSPServer.respondDescribe (C:\Users\User\node-rtsp-rtmp-server\rtsp.js:1490:19)
    at RTSPServer.respond (C:\Users\User\node-rtsp-rtmp-server\rtsp.js:2047:21)
    at RTSPServer.handleOnData (C:\Users\User\node-rtsp-rtmp-server\rtsp.js:1051:19)
    at Socket.<anonymous> (C:\Users\User\node-rtsp-rtmp-server\rtsp.js:512:28)

Also, using Big_buck_bunny.mp4 from http://camendesign.com/code/video_for_everybody/test.html.

use FFmpeg Publish Failed.

Error: [rtmp:publish] malformed audio data: AudioSpecificConfig is missing
at RTMPSession.parseAudioMessage (e:\git\rtmpserver\rtmp.coffee:741:21)
at e:\git\rtmpserver\rtmp.coffee:1889:28
at RTMPSession.handleData (e:\git\rtmpserver\rtmp.coffee:1959:7)
at Socket. (e:\git\rtmpserver\rtmp.coffee:1994:23)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:529:20)

The source is ts over http.

use FMS no problem

Server shutting down with "server.coffee: 40 throws err: TypeError: Object blalbabla"

Hi!
I'm testing this server with 2 types of rtmp streamers - Flash Media Encoder and Teradek VidiU mini (hardware streamer for hdmi cameras)
It's all ok with first one, but i tried to connect VidiU mini, that supports RTMP streaming with h.264, and server fail's with unhandled exception (debug log listed below)
Any ideas? Please help

2015-07-08 12:16:16.964 [rtmp:BElYtzPD] connected
[rtmp: 1 sessions]
BElYtzPD: addr=91.202.72.98 port=39328
2015-07-08 12:16:16.968 [rtmp:handshake] warning: unknown message format, assuming format 1
2015-07-08 12:16:31.559 [rtmp:zXrA8Myz] connected
[rtmp: 2 sessions]
BElYtzPD: addr=91.202.72.98 port=39328
zXrA8Myz: addr=176.115.97.245 port=51143
2015-07-08 12:16:31.617 [rtmp:handshake] warning: unknown message format, assuming format 1
2015-07-08 12:16:32.849 [rtmp] publish: stream=zzz publishingType=live
2015-07-08 12:16:32.951 receive video: num_nal_units=2 pts=165473106840
2015-07-08 12:16:32.954 video: pts=165473106840 pts_diff=165473106840 md5=2b2606d nal_unit_type=7 bytes=44
2015-07-08 12:16:32.954 video: pts=165473106840 pts_diff=0 md5=ac995ac nal_unit_type=8 bytes=4
2015-07-08 12:16:32.957 receive audio: num_access_units=1 pts=165473112600
2015-07-08 12:16:32.957 audio: pts=165473112600 md5=b504dda bytes=92
2015-07-08 12:16:33.177 receive video: num_nal_units=4 pts=165473106840

/home/ubuntu/node-rtsp-rtmp-server/server.coffee:40
throw err;
^
TypeError: Object gB�^_�(.7��"

RTMPT support over port 80

It would be good to provide support for this. Lots of users are stuck behind firewalls so I think this is really needed at some point. If I knew the protocol well enough I'd try and chip in.

HTTP API

Is it possible to create an HTTP API to query who are publishing, with what resolution, how much listeners there are.

Im open to do it myself if you could point me to the right direction :)

Troubles starting the server

I have downloaded the repository but i cant run the server. I'm on MacOs.

sudo coffee server.coffee
2016-05-24 10:34:51.098 attachRecordedDir: dir=file app=file
/Users/Sergio/Sites/node-rtsp-rtmp-server/server.coffee:46
    throw err;
    ^

Error: listen EADDRINUSE 0.0.0.0:1935
  at Object.exports._errnoException (util.js:837:11)
  at exports._exceptionWithHostPort (util.js:860:20)
  at Server._listen2 (net.js:1231:14)
  at listen (net.js:1267:10)
  at net.js:1376:9
  at doNTCallback3 (node.js:440:9)
  at process._tickCallback (node.js:346:17)
  at Function.Module.runMain (module.js:473:11)
  at startup (node.js:117:18)
  at node.js:951:3

Single stream / Multiple connections - Last connection is terminated prematurely?

Hi,

I've been using your excellent picam in combination with node-rtsp-rtmp-server. It seems to work pretty nicely, except I've noticed that when there are multiple connections, the last one left connected gets prematurely disconnected when the second remaining disconnects.

Eg Clients A, B and C all connect. C disconnects, then A and B remain connected (fine). B disconnects, A also gets disconnected (prematurely).
Similarly - A and B connect, B disconnects, then A also gets disconnected (prematurely).

The count of clients connected appears to be correct in the STDOUT log output when monitoring the above scenarios. I'm using RTSP and connecting via a mixture of OS X and iOS vlc clients.

G

Unknown AMF0 data type: 17

Trying to stream from Action Script 3:

Error: Unknown AMF0 data type: 17
at parseAMF0Data (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:264:15)
at parseAMF0DataMessage (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:202:14)
at E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2516:29
at Sequent. (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2433:11)
at Sequent.done (E:\cht\node-rtsp-rtmp-server-master\node_modules\sequent\lib\sequent.js:151:34)
at E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2546:21
at RTMPSession.respondPublish (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:1462:5)
at RTMPSession.handleAMFCommandMessage (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2325:10)
at E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2541:16
at RTMPSession.handleData (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2580:7)
at Socket. (E:\cht\node-rtsp-rtmp-server-master\rtmp.coffee:2615:23)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:529:20)

Code used: Link to PasteBin

Can this module tunnel RTSP over HTTP?

The documentation doesn't have an example for taking an incoming RTSP stream and publishing it via HTTP. Looking at the code it seems like http tunneling is supported for posting an RTSP stream... but I didn't see how I would tunnel RTSP over HTTP as per the QuickTime spec: http://www.opensource.apple.com/source/QuickTimeStreamingServer/QuickTimeStreamingServer-412.42/Documentation/RTSP_Over_HTTP.pdf

Any guidance? Is this already in this module or am I looking for a feature that isn't there?

Some documents about rtsp relay server.

Hi,
I want to implement a little tool which can receive rtsp stream from ffmpeg and relay it to VLC.
I want to use Python or Java. But I couldn't find docs about the principle of rtsp relay. So, could you give me some advice about how you implement your application.
Thanks !

ffmpeg stream to server times out

Also, Windows 7.

$ ffmpeg.exe -i test.mp4 -c:v copy -c:a copy -f flv rtmp://localhost:3000/live/stream         
ffmpeg version N-75794-gd1c8368 Copyright (c) 2000-2015 the FFmpeg developers                                                    
  built with gcc 5.2.0 (GCC)                                                                                                     
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enabl
e-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec -
-enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore
-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsox
r --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --en
able-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-l
ibxvid --enable-lzma --enable-decklink --enable-zlib                                                                             
  libavutil      55.  2.100 / 55.  2.100                                                                                         
  libavcodec     57.  4.100 / 57.  4.100                                                                                         
  libavformat    57.  3.100 / 57.  3.100                                                                                         
  libavdevice    57.  0.100 / 57.  0.100                                                                                         
  libavfilter     6. 10.100 /  6. 10.100                                                                                         
  libswscale      4.  0.100 /  4.  0.100                                                                                         
  libswresample   2.  0.100 /  2.  0.100                                                                                         
  libpostproc    54.  0.100 / 54.  0.100                                                                                         
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'work1.mp4':                                                                             
  Metadata:                                                                                                                      
    major_brand     : isom                                                                                                       
    minor_version   : 512                                                                                                        
    compatible_brands: isomiso2avc1mp41                                                                                          
    creation_time   : 1970-01-01 00:00:00                                                                                        
    encoder         : Lavf53.24.2                                                                                                
  Duration: 00:01:02.32, start: 0.000000, bitrate: 1347 kb/s                                                                     
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 959 kb/s, 25 fps, 25 tbr, 128
00 tbn, 50 tbc (default)                                                                                                         
    Metadata:                                                                                                                    
      creation_time   : 1970-01-01 00:00:00                                                                                      
      handler_name    : VideoHandler                                                                                             
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 383 kb/s (default)                               
    Metadata:                                                                                                                    
      creation_time   : 1970-01-01 00:00:00                                                                                      
      handler_name    : SoundHandler                                                                                             
RTMP_Connect1, handshake failed.                                                                                                 
rtmp://localhost:3000/live/stream: Unknown error occurred

Server's Log:

$ node server.js
2016-06-14 11:40:14.223 attachRecordedDir: dir=file app=file
2016-06-14 11:40:14.237 [rtmp] server started on port 8080
2016-06-14 11:40:14.237 [rtsp/http/rtmpt] server started on port 3000
2016-06-14 11:40:17.798 [rtsp/http/rtmpt:client=c1] connected

Possibility to rewind stream?

Hi

This is more a request then an issue, but I was wondering if it's possible to rewind/pause a stream?

Greetings
Jarno

RTMPT does not work

I can successfully watch a rtmp stream, but the same stream will not play in rtmpt. I'm using ffmpeg as the publisher and the client. I verified ffmpeg/ffprobe cannot watch the rtmpt stream, and that Strobe Media Player also cannot play it. ffmpeg is version 2.7.1

Here is my log below.

2015-08-20 03:46:52.556 [rtmp] server started on port 1936
2015-08-20 03:46:52.562 [rtsp/http] server started on port 8086
2015-08-20 03:46:57.272 [rtmp:zQdGgS7h] connected
[rtmp: 1 sessions]
 zQdGgS7h: addr=127.0.0.1 port=55751
2015-08-20 03:46:57.281 [rtmp:handshake] warning: unknown message format, assuming format 1
2015-08-20 03:46:57.293 [rtmp:receive] unknown (not implemented) AMF command: _checkbw
2015-08-20 03:46:57.295 [rtmp] publish: stream=1 publishingType=live
2015-08-20 03:47:06.667 [rtsp/http] client c1 connected
[rtsp/http: 1 clients]
 c1: session=44137417 addr=127.0.0.1 port=48825 type=rtmpt
[rtmp: 1 sessions]
 zQdGgS7h: addr=127.0.0.1 port=55751
[rtmpt: 1 sessions]
 061d6693fbf4377b198168478b581a0: rtmp_session=U4ijXMXY created_at=Thu Aug 20 2015 03:47:06 GMT+0000 (UTC)
2015-08-20 03:47:06.680 [rtmp:handshake] warning: unknown message format, assuming format 1
2015-08-20 03:47:06.724 [rtmp:receive] unknown (not implemented) AMF command: _checkbw
2015-08-20 03:47:06.763 [rtmp:U4ijXMXY] requested stream 1
2015-08-20 03:47:06.765 [rtmp:U4ijXMXY] waiting for keyframe
2015-08-20 03:47:09.913 [rtmp:U4ijXMXY] started streaming
2015-08-20 03:47:36.831 [rtmpt:U4ijXMXY] close
2015-08-20 03:47:36.832 [rtmpt:U4ijXMXY] received teardown
2015-08-20 03:47:36.833 Socket error (c1): Error: write after end
2015-08-20 03:47:36.834 [rtsp/http] client c1 is closed
[rtsp/http: 0 clients]

Can't connect from VLC

Dear sir,

I publish video over RTSP by ffmpeg. But I can't connect to the stream from VLC player.
This is the issue call back in Terminal
2016-03-26 08:20:03.202 [rtsp/http/rtmpt:client=c5] disconnected [rtsp/http: 1 clients] c1: session=96364581 addr=118.69.30.249 port=44804 type=publish-udp 2016-03-26 08:20:03.243 [rtsp/http/rtmpt:client=c6] connected 2016-03-26 08:20:03.407 [rtsp/http/rtmpt:client=c6] start streaming over TCP [rtsp/http: 2 clients] c1: session=96364581 addr=118.69.30.249 port=44804 type=publish-udp c6: session=53339965 addr=118.69.30.249 port=44819 type=tcp isPlaying=true 2016-03-26 08:20:14.042 [rtsp/http/rtmpt:client=c6] disconnected [rtsp/http: 1 clients] c1: session=96364581 addr=118.69.30.249 port=44804 type=publish-udp 2016-03-26 08:21:59.959 [rtsp/http/rtmpt:client=c1] finished uploading stream live/test 2016-03-26 08:21:59.963 [rtsp/http/rtmpt:client=c1] disconnected [rtsp/http: 0 clients]

Please help me resolved this.

multiple streams are not supported

Could you please explain why multiple streams are not supported? README said, that "you can push only one stream at a time". Does it mean, that we cant publish more than one RTMP live stream at a time? Thanks.

add functionalty to save stream to file

Hi. I would like to be able to save the user webcam to disk. I am looking forward to you adding support for multiple publishers (another issue) but for my purpose i need a way to save the rtmp to disk. Dumping a flv file would be just fine.

What do you think about this ? is it easy ? Do you plan to do it yourself ? if not where could i start from ?

I know I could just connect a gstreamer client pipeline or use rtmpdump to save the stream to disk but i would like to do it in the same process (not having one process per publisher) and I don't want to loose the very first frame so it has to be tightly integrated I think.

Thank you very much for your work i totally love the idea of a Coffee/js/node.js based streaming server.

"Waiting for keyframe"

Hi! It all works when trying to stream mp4 video, but when I try to encode other videos to mp4 — I got this:
2015-03-18 01:50:00.759 [rtmp] waiting for the key frame for client 9x3LDXUc
and it only works only when I connect exact at the beginning of stream.

The only solution is to use -g 1 option. But it seems to be very strange, because parameter for g need to be at least fps*2, not every frame!

ffmpeg -re -i video.avi -vcodec libx264 -g 1 -acodec libvo_aacenc -ar 44100 -ac 2 -f flv rtmp://localhost/live/myStream

Is it my mistake?

Message lengths don't match stream via Flash Encoder

2016-01-01 16:06:43.443 Please report this bug on GitHub. Thanks.
2016-01-01 16:06:43.443 https://github.com/iizukanao/node-rtsp-rtmp-server/issues
2016-01-01 16:06:43.443 ---------------
2016-01-01 16:06:45.127 [rtmp] warning: message lengths don't match: got=28928 expected=946
2016-01-01 16:06:45.127 ----- BUG -----
2016-01-01 16:06:45.127 [rtmp:receive] received unknown (not implemented) message type ID: 210
2016-01-01 16:06:45.127 { formatType: 0,
chunkStreamID: 16,
timestamp: 12760489,
timestampDelta: 0,
messageLength: 946,
messageTypeID: 210,
messageStreamID: 49361467,
body: <Buffer 91 81 01 77 21 24 71 14 80 19 0a c4 c9 bb 09 a0 84 00 00 2e 16 bf fb d9 b2 1c 18 21 82 1a 71 60 03 12 0c 9b f8 9a 8b db 9a b1 a4 20 25 03 19 89 b6 03 40 ...> }
2016-01-01 16:06:45.127 Please report this bug on GitHub. Thanks.
2016-01-01 16:06:45.127 https://github.com/iizukanao/node-rtsp-rtmp-server/issues
2016-01-01 16:06:45.128 ---------------

Unable to stream video on Mac OSX

Hi,

I am trying to set up streaming video using this project but I can't get it to work. Here is what I am doing:

  1. recorded a video using vlc. Key settings - encapsulation method MPEG4, video encoding - h264, bitrate - tried a few combos, even as high as 2048, Audio - disabled (just to get video working)
  2. Conformed that the video plays back in vlc
  3. changed rtsp port to 8080 and run server.coffee
  4. published the video to your server by doing:
    ffmpeg -re -i ~/test.mp4 -c:v copy -c:a copy -f flv rtmp://localhost/live/myStream
  5. Open the stream using vlc, display to screen

What I notice is that vlc will only start playback iff I point vlc to your rtsp server BEFORE running the ffmpeg command. Even so, I only get the video screen loading up and it does not change beyond what opens initially. The Initial screen also only shows the video in a part of the window. The rest is distorted/greyed out horribly.

Any thoughts on what I am doing wrong?

Reg ex issue found in avstream for windows path.sep charaters

Hi

When playing back a recorded mp4 file using the new features you've recently added (thanks for that!), I get an error relating to the regEx expression around line 350 (avstream.coffee)

Error:
SyntaxError: Invalid regular expression: /(^|)..(|$)/: Unterminated group

I believe is only seen when running node under windows and the fact that the path separator is a backslash and needs to be escaped within a regEx expression.

I added a quick fix local fix

 # Check that filename is legitimate
          pathSep = path.sep
          pathSep += "\\" if (pathSep == "\\")                

          if (filename is '.') or
          new RegExp("(^|#{pathSep})..(#{pathSep}|$)").test filename
            logger.warn "rejected request to stream: #{streamId}"
            break

I've only tested this on windows 8.

Thanks

simple nodejs example

Hello there, I just started using node.js and installed node-rtsp-rtmp-server via npm.
So I'm stuck with how to setup it...
I have included it into my server but I'm not sure how to call and setup it.

var module_http = require('http');
var module_ecstatic = require('ecstatic');
var module_stream = require('node-rtsp-rtmp-server');

const server_port = 1313;
var server_options =
{
    root: __dirname + '/public',
    port: server_port,
    baseDir: '/',
    cache: 3600,
    showDir: true,
    showDotfiles: true,
    autoIndex: true,
    humanReadable: true,
    headers: {},
    si: false,
    defaultExt: 'html',
    gzip: false,
    serverHeader: true,
    contentType: 'application/octet-stream',
    mimeTypes: undefined,
    handleOptionsMethod: false
};

module_http.createServer(module_ecstatic(server_options)).listen(server_port);

console.log('Listening on : ' + server_port);

If anyone could help me, that would be great!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.