rtsp-relay
Node.js server to relay RTSP video stream from 'producer' to 'consumer' client endpoint.
The Problem:
- I was looking at Android apps that stream video
- of the display screen
- from the camera/microphone
- surprisingly, there are very few good options
- the only stream protocol they support is RTSP
- I'm no expert, but apparently:
- this protocol requires the app to connect (as a client) to an external media server
- the video stream is published to the server
- clients must then connect to this server, in order to subscribe to (and view) the video stream
- I'm no expert, but apparently:
Attempted Workarounds:
-
rtsp-simple-server
- pros:
- written in golang, so it cross-compiles statically linked binaries for several platforms
- small size
- no dependencies
- portable
- simple to use
- both 'producer' and 'consumer' connect to the same URL:
rtsp://[IP]:8554/[stream_id]
- both 'producer' and 'consumer' connect to the same URL:
- cons:
-
v0.10.1
isn't fully compatible with the Android app I was testing: Larix Screencasterv1.0.29
- it would repeatedly: connect, work a few seconds, disconnect
-
- pros:
This Workaround:
- based on: rtsp-streaming-server
- written by: Chris Wiggins
- written in: TypeScript
- inspired by: rtsp-server
- written by: Mischa Spiegelmock
- written in: Perl
- changes:
- converted from TypeScript to ES6 syntax
- why:
- I fkn hate TypeScript
- now it can run in node without being transpiled
- how:
- rebased to
v1.0.2
- manually merged subsequent updates
- rebased to
- why:
- added a CLI
- converted from TypeScript to ES6 syntax
- limitations (inherited from rtsp-streaming-server library)
- doesn't support RTP/RTSP/TCP
- which is:
- a strategy to interleave the RTP packets into the (TCP) RTSP stream, rather than allocating 2x additional (UDP) RTP and RTCP ports per stream
- for example:
- SETUP request from 'producer':
SETUP rtsp://192.168.0.100:5554/screen/streamid=0 RTSP/1.0 Transport: RTP/AVP/TCP;unicast;interleaved=0-1;mode=record User-Agent: Larix/1.0.29
- response:
501 Not implemented
- SETUP request from 'producer':
- which is:
- doesn't support RTP/RTSP/TCP
- status:
- Android 'producer' apps/libraries that have been successfully tested with
rtsp-relay
-
libstreaming
- library
- demo app:
example3
-
- Android 'consumer' apps/libraries that have been successfully tested with
rtsp-relay
-
ExoPlayer
pull request 3854- library
- demo app:
RTSP IPCam Viewer
- source code repo
- prebuilt apks (signed by me)
-
- cross-platform 'consumer' apps/libraries that have been successfully tested with
rtsp-relay
- Android 'producer' apps/libraries that have been successfully tested with
Installation:
npm install --global @warren-bank/rtsp-relay
CLI Usage:
rtsp-relay <options>
options:
========
"--help"
Print a help message describing all command-line options.
"-v"
"--version"
Display the version.
"-pport" <integer>
"--producer-port" <integer>
[optional] Port number for RTSP server to which the 'producer' connects.
Default: 5554
"-pu" <username>
"--producer-username" <username>
[optional] Authenticate connections to 'producer' port with secret 'username'.
"-pp" <password>
"--producer-password" <password>
[optional] Authenticate connections to 'producer' port with secret 'password'.
"-cport" <integer>
"--client-port" <integer>
"--consumer-port" <integer>
[optional] Port number for RTSP server to which the 'consumer' connects.
Default: 6554
"-cu" <username>
"--client-username" <username>
"--consumer-username" <username>
[optional] Authenticate connections to 'consumer' port with secret 'username'.
"-cp" <password>
"--client-password" <password>
"--consumer-password" <password>
[optional] Authenticate connections to 'consumer' port with secret 'password'.
"-rlp" <integer>
"--rtp-low-port" <integer>
[optional] Low end of UDP port number range for RTP server.
Default: 10000
"-rhp" <integer>
"--rtp-high-port" <integer>
[optional] High end of UDP port number range for RTP server.
Default: 20000
"-L" <integer>
"--log" <integer>
"--log-level" <integer>
[optional] Enumeration value to specify log output filter.
Values:
-1: custom: obey DEBUG environment variable
0: silent
1: quiet
2: debug quiet
3: debug verbose
4+: verbose
Default: 1
Legal:
- copyright: Warren Bank
- license: GPL-2.0