A stream published on the WCS server can be played via RTSP in a third-party player. In this case, WCS itself serves as an RTSP-source.
- Video: H.264, VP8, H265 (since build 5.2.1577)
- Audio: AAC, G.711, Speex
- The browser establishes a connection to the server via Websocket
- The browser captures the camera and the microphone and sends the WebRTC stream to the server
- VLC Player establishes a connection to the server via RTSP
- VLC Player receives the stream from the server and plays it
Quick manual on testing
Publishing a video stream on the server and playing it via RTSP in a software player
1. For the test we use:
- the demo server at demo.flashphoner.com;
- the Two Way Streaming web application to publish the stream;
- VLC Player to play the stream.
2. Open the Two Way Streaming application. Click Connect, then Publish. Copy the identifier of the stream:
3. Run VLC, select the "Media - Open network stream" menu. Enter the URL of the WCS server and enter the identifier of the stream, in this exampe:
4. Click the "Play" button. The player starts playing the stream:
Below is the call flow when playing a stream via RTSP in a software player.
- The software player establishes a connection to the WCS server via RTSP.
- The software player receives the media stream from WCS.
RTSP server configuration
By default, TCP port 554 is used to listen RTSP connections. This value can be set with the following parameter in flashphoner.properties file
Since build 5.2.801, WCS is running from 'flashphoner' user for security reasons. Therefore RTSP server may not be launched because TCP ports in range 0-1000 are privileged and unavailable to non-root users. In this case RTSP port should be changed, for example
RTSP playback authentication via REST hook
When RTSP connection is established, /playRTSP query will be sent to backend server application defaultApp
Such query will be sent on using every RTSP method excepting OPTIONS. If backend server responds 200 OK, WCS server allows to execute RTSP method and to play RTSP stream. If backend server returns 403 Forbidden, WCS server breaks the connection with RTSP client.
Thus, RTSP client can be authenticated by RTSP stream URL, User-Agent, client and server IP address and port.
Custom access key and backend application usage for RTSP playback authentication
Since build 5.2.1008 it is possible to set ccustom authentication key (token) in RTSP URL, for example
The following REST hook /playRTSP content will be sent to defaultApp backend application
Authentication token name is set by the following parameter as like for HLS playback
It is also possible to set custom backend application key
In this case REST hook /playHLS will be sent to backend application with defined key (customAppKey in the example above).
Adjusting RTSP playback parameters
To adjust RTSP playback parameters, for example, to change audio or video codec, SDP setting file rtsp_server.sdp should be used. Note that this file should contain WCS server IP address.
Playing H265 without transcoding
Streams published in H264, VP8, or MPV codecs may not be played as H265! Use this codec to play MPEG-TS H265 streams only
Dynamic codec detection
Since build 5.2.1592 codecs are detected dynamically for RTSP playback
In this case, if a stream is published as H264, VP8 or H265, and RTSP client supports the codec, the stream will be played via RTSP without transcoding. Audio codecs are detected by the same way.
Interleaved mode support
Before build 5.2.1609, WCS supported interleaved mode only, in this case both RTSP signaling and RTP traffic go via TCP, therefore some player applications (including VLC) may not play RTSP from WCS with default settings. Since build 5.2.1609, non-interleaved mode is also supported, in this case RTSP signaling goes via TCP, and RTP traffic flows via UDP. Note that non-interleaved mode is less packet loss proof.
1. Frame loss and picture artefacts can occur when HD stream is played via RTSP
Symptoms: some artefacts are observed, and player log contains lost frame reports when HD stream is played via RTSP.
Solution: switch player to RTSP interleaved mode, for example, in VLC settings tab Input/Codecs set radiobutton Live 555 stream transport to RTP over RTSP (TCP)
2. Freezes can occur when WebRTC stream is played via RTSP, if player recieves no key frame
Symptoms: freezes when WebRTC stream is played as RTSP in VLC player
Solution: enable the following setting in flashphoner.properties file
3. When stream is played as RTSP in VLC on Windows, audio samplerate and bitrate can be displayed incorrectly due to VLC known bug.