node-rtsp-rtmp-server
所属分类:流媒体/Mpeg4/MP4
开发工具:CoffeeScript
文件大小:122KB
下载次数:0
上传日期:2021-09-22 14:42:39
上 传 者:
sh-1993
说明: RTSP RTMP HTTP混合服务器
(RTSP RTMP HTTP hybrid server)
文件列表:
CHANGELOG.md (573, 2021-09-22)
Dockerfile (628, 2021-09-22)
LICENSE (1077, 2021-09-22)
Makefile (453, 2021-09-22)
aac.coffee (21983, 2021-09-22)
avstreams.coffee (14305, 2021-09-22)
bits.coffee (13781, 2021-09-22)
codec_utils.coffee (213, 2021-09-22)
config.coffee (4559, 2021-09-22)
custom_receiver.coffee (8213, 2021-09-22)
entrypoint.sh (255, 2021-09-22)
event_emitter.coffee (3033, 2021-09-22)
example (0, 2021-09-22)
example\mp4dump.coffee (263, 2021-09-22)
example\tcp.coffee (6810, 2021-09-22)
example\udp.coffee (7347, 2021-09-22)
example\unix.coffee (6839, 2021-09-22)
file (0, 2021-09-22)
flv.coffee (6952, 2021-09-22)
h264.coffee (36339, 2021-09-22)
http.coffee (14426, 2021-09-22)
hybrid_udp.coffee (13216, 2021-09-22)
logger.coffee (2022, 2021-09-22)
mp4.coffee (68591, 2021-09-22)
mpegts.coffee (34514, 2021-09-22)
package.json (369, 2021-09-22)
public (0, 2021-09-22)
public\index.html (129, 2021-09-22)
rtmp.coffee (104999, 2021-09-22)
rtmp_handshake.coffee (4851, 2021-09-22)
rtp.coffee (28535, 2021-09-22)
rtsp.coffee (80428, 2021-09-22)
sdp.coffee (11431, 2021-09-22)
server.coffee (1105, 2021-09-22)
start_server.sh (37, 2021-09-22)
stream_server.coffee (13000, 2021-09-22)
... ...
### RTSP, RTMP, and HTTP server in Node.js
- Supports RTSP, RTMP/RTMPE/RTMPT/RTMPTE, and HTTP.
- Supports only H.2*** 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](https://coffeescript.org/) 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 Flash Media Live Encoder
Flash Media Live Encoder is a free live encoder from Adobe.
In the Encoding Options panel, check "Stream to Flash Media Server" and set the URL to:
- **FMS URL**: rtmp://localhost/live
- **Backup URL**: (blank)
- **Stream**: STREAM_NAME (whatever name you would like)
Press the "Connect" button. Set the video format to H.2***, and the audio format to AAC. Press the "Start" button.
When you watch the stream over RTSP or RTMP, use the stream name specified above.
#### From FFmpeg
If you have an MP4 file with H.2*** 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 libx2*** -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 libx2*** -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 libx2*** -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.2*** 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 ! h2***parse ! 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 ! \
x2***enc bitrate=256 tune=zerolatency ! h2***parse ! 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 for Flash Player. Flowplayer and JW Player are both good free players.
**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
近期下载者:
相关文件:
收藏者: