...
A video stream is captured from an RTSP source that provides audio and video in the supported codecs. Then, the server transforms this video stream for playing in browsers and mobile devices.
RTSP sources
...
- IP cameras
- Media servers
- Surveillance systems
- Conference servers
Supported codecs
...
- H.264
- VP8
- AAC
- G.711
- Speex
Supported platforms and browsers
...
A REST-query should be HTTP/HTTPS POST request as follows:
- HTTP: http://test.flashphoner.com:90918081/rest-api/rtsp/startup
- HTTPS: https://test.flashphoner.com:88888444/rest-api/rtsp/startup
Where:
- test.flashphoner.com - is the address of the WCS server
- 9091 8081 - is the standard REST / HTTP port of the WCS server
- 8888 8444 - is the standard HTTPS port
- rest-api - is the required part of the URL
- /rtsp/startup - REST-method to use
REST-methods and response statuses
REST-method | Example of REST-query | Example of response | Response statuses | Description | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
/rtsp/startup |
| 409 - Conflict 500 - Internal error | Pull the RTMP stream by the specified URL | ||||||||
/rtsp/find_all |
| 200 – streams found | Find all pulled RTMP-streams | ||||||||
/rtsp/terminate |
| 200 - stream terminated | Terminate the pulled RTMP stream |
Parameters
Parameter name | Description | Example |
---|---|---|
uri | URL of the RTSP stream | |
status | Current status of the stream | PLAYING |
Call flow
Below is the call flow when using the Player example
...
Code Block | ||||
---|---|---|---|---|
| ||||
function playStream(session) { var streamName = $('#streamName').val(); var options = { name: streamName, display: remoteVideo, flashShowFullScreenButton: true }; ... stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) { var video = document.getElementById(stream.id());... }); if (!video.hasListeners) { video.hasListeners = true;stream.play(); } |
4. Request from WCS to the RTSP source to broadcast the stream.
5. Broadcasting the RTSP stream
6. Receiving from the server an event confirming successful capturing and playing of the stream.
StreamStatusEvent, статус PLAYING code
Code Block | ||||
---|---|---|---|---|
| ||||
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) { ... video}).addEventListener('playing'on(STREAM_STATUS.PLAYING, function (stream) { $("#preloader").hideshow(); }setStatus(stream.status()); video.addEventListener('resize', function (event) {onStarted(stream); ... var streamResolution =}); stream.videoResolutionplay(); |
7. Sending audio- and video stream via WebRTC
8. Stopping playing the stream.
stream.stop(); code
Code Block | ||||
---|---|---|---|---|
| ||||
function onStarted(stream) { if (Object.keys(streamResolution).length === 0) $("#playBtn").text("Stop").off('click').click(function(){ $(this).prop('disabled', true); resizeVideo(event.targetstream.stop(); } else }).prop('disabled', false); $("#fullScreenBtn").off('click').click(function(){ stream.fullScreen(); }).prop('disabled', false); // Change aspect ratio to prevent video stretching$("#volumeControl").slider("enable"); var ratio = streamResolution.width / streamResolution.height; stream.setVolume(currentVolumeValue); } |
9. Receiving from the server an event confirming successful stop of the stream playback.
StreamStatusEvent, статус STOPPED code
Code Block | ||||
---|---|---|---|---|
| ||||
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) { var... newHeight = Math}).flooron(options.playWidth / ratio);STREAM_STATUS.PLAYING, function(stream) { ... resizeVideo(event.target, options.playWidth, newHeight);}).on(STREAM_STATUS.STOPPED, function() { setStatus(STREAM_STATUS.STOPPED); } onStopped(); }).on(STREAM_STATUS.FAILED, function(stream) { });... }}).on(STREAM_STATUS.NOT_ENOUGH_BANDWIDTH, function(stream){ ... }); stream.play(); } |
4. Request from WCS to the RTSP source to broadcast the stream.
5. Broadcasting the RTSP stream
6. Receiving from the server an event confirming successful capturing and playing of the stream.
...
RTSP connection reuse
If other subscrubers request the stream captured from RTSP IP camera, the previous RTSP connection will be used if all subscribers set the same camera URL. For example, two requests to the same IP camera
Code Block | ||||
---|---|---|---|---|
| ||||
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
...
}).on(STREAM_STATUS.PLAYING, function(stream) {
$("#preloader").show();
setStatus(stream.status());
onStarted(stream);
...
});
stream.play();
|
7. Sending audio- and video stream via WebRTC
8. Stopping playing the stream.
stream.stop(); code
Code Block | ||||
---|---|---|---|---|
| ||||
function onStarted(stream) {
$("#playBtn").text("Stop").off('click').click(function(){
$(this).prop('disabled', true);
stream.stop();
}).prop('disabled', false);
$("#fullScreenBtn").off('click').click(function(){
stream.fullScreen();
}).prop('disabled', false);
$("#volumeControl").slider("enable");
stream.setVolume(currentVolumeValue);
} |
9. Receiving from the server an event confirming successful stop of the stream playback.
StreamStatusEvent, статус STOPPED code
Code Block | ||||
---|---|---|---|---|
| ||||
stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
...
}).on(STREAM_STATUS.PLAYING, function(stream) {
...
}).on(STREAM_STATUS.STOPPED, function() {
setStatus(STREAM_STATUS.STOPPED);
onStopped();
}).on(STREAM_STATUS.FAILED, function(stream) {
...
}).on(STREAM_STATUS.NOT_ENOUGH_BANDWIDTH, function(stream){
...
});
stream.play(); |
Known issues
1. A stream containing B-frames does not play or plays with artifacts (latencies, lags)
Symptoms:
- a stream sent by the IP camera via RTSP does not play or plays with latencies or lags
- warnings in the client log:
Code Block | ||||
---|---|---|---|---|
| ||||
09:32:31,238 WARN 4BitstreamNormalizer - RTMP-pool-10-thread-5 It is B-frame! |
Solution: request lower resolution video from the camera to avoid using B-frames or transcode that stream.
2. Connection to the IP camera is lost on error in any track (audio or video)
Symptoms: connection to the IP camera is lost if one of tracks returns error 4**.
Solution: this behavior is enabled by default. However if one-time errors are not critical and should not terminate broadcasting, in the flashphoner.properties files set
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp_fail_on_error_track=false
rtp_force_synchronization=true |
3. AAC frames of type 0 are not supported by decoder and will be ignored while stream pulled playback
In this case, warnings will be displayed in the client log:
Code Block | ||||
---|---|---|---|---|
| ||||
10:13:06,815 WARN AAC - AudioProcessor-c6c22de8-a129-43b2-bf67-1f433a814ba9 Dropping AAC frame that starts with 0, 119056e500 |
...
rtsp://host:554/live.sdp |
and
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp://host:554/live.sdp?p=1 |
are differ, then two RTSP connections will be created if streams from both URLs are requested.
Stream capture authentication
WCS supports RTSP stream capture authentication by user name and password, user data should be set in stream URL, for example
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp://user:password@hostname/stream |
If name or password contains any special characters, they should be escaped such as
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp://user:p%40ssword@hostname/stream |
Where
- user is user name
- p@ssword is password with character '@', it is escaped in URL.
Known issues
Excerpt Include | ||||||
---|---|---|---|---|---|---|
|
5. Connection to the IP camera is lost on error in any track (audio or video)
Symptoms: connection to the IP camera is lost if one of tracks returns error 4**.
Solution: this behavior is enabled by default. However if one-time errors are not critical and should not terminate broadcasting, in the flashphoner.properties files set
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp_fail_on_error_track=false
rtp_force_synchronization=true |
6. All the characters in a stream name, that are not allowed in URI, should be escaped
Symptoms: RTSP stream is not played with 'Bad URI' error
Solution: any character that is not allowed in URI, should be escaped in stream URL, for example
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp://hostname/c@@lstream/channel1 |
should be set as
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp://hostname/c%40%40lstream/channel1 |
7. Some IP cameras do not support cnonce
field in RTSP connection message header.
Symptoms: RTSP stream is played with VLC, but is not played with WCS.
Solution: set the following parameter in flashphoner.properties file
Code Block | ||||
---|---|---|---|---|
| ||||
rtsp_auth_cnonce= |
with empty value.