...
Since WCS build 5.2.1193 it is possible to publish MPEG-TS RTP stream via UDP to WCS, and since build 5.2.1253 MPEG-TS stream may be published via SRT. The feature can be used to publish H264+AAC stream from software or hardware encoder supporting MPEG-TS. Since build 5.2.1577 H265+AAC stream publishing is also allowed.
SRT protocol is more reliable than UDP, so it is recommended to use SRT for MPEG-TS publishing if possible.
Codecs supported
- H264
- H265 (since build 5.2.1577)
- AAC
Operation flowchart
1. Publisher sends REST API query /mpegts/startup
...
Code Block | ||||
---|---|---|---|---|
| ||||
{ "localMediaSessionId": "32ec1a8e-7df4-4484-9a95-e7eddc45c508", "localStreamName": "test", "uri": "srt://test1.flashphoner.com:31014", "status": "CONNECTED", "hasAudio": truefalse, "hasVideo": truefalse, "record": false, "transport": "SRT", "cdn": false, "timeout": 90000, "maxTimestampDiff": 1, "allowedList": 90000[] } |
UDP:
Code Block | ||||
---|---|---|---|---|
| ||||
{ "localMediaSessionId": "32ec1a8e-7df4-4484-9a95-e7eddc45c508", "localStreamName": "test", "uri": "udp://test1.flashphoner.com:31014", "status": "CONNECTED", "hasAudio": truefalse, "hasVideo": truefalse, "record": false, "transport": "UDP", "cdn": false, "timeout": 90000, "maxTimestampDiff": 90000 1, "allowedList": [] } |
4. Publish MPEG-TS stream using URI from the response
...
REST method | REST query body example | REST response body example | Response states | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
/mpegts/startup |
|
| 200 - OK 409 - Conflict 500 - Internal error | Start MPEG-TS publishing | ||||||||||||||
/mpegts/find |
|
| 200 – streams found 404 – streams not found 500 - Internal error | Find the MPEG-TS stream by criteria | ||||||||||||||
/mpegts/find_all |
| 200 – streams found 404 – streams not found 500 - Internal error | Find all MPEG-TS streams | |||||||||||||||
/mpegts/terminate |
| 200 - stream stopped 404 - stream not found 500 - Internal error | Stop MPEG-TS stream |
...
Name | Description | Example |
---|---|---|
localStreamName | Name to set to the stream on server | test |
transport | Transport to use | srt |
uri | Endpoint URI to publish the stream | udp://192.168.1.39:31014 |
localMediaSessionId | Stream media session Id | 32ec1a8e-7df4-4484-9a95-e7eddc45c508 |
status | Stream status | CONNECTED |
hasAudio | Stream has audio track | true |
hasVideo | Stream has video track | true |
record | Stream is recording | false |
timeout | Maximum media data receiving timeout, ms | 90000 |
maxTimestampDiff | Maximum stream timestamps difference, ms90000s | 1 |
allowedList | Client addresses list which are allowed to publish the stream |
|
Audio only or video only publishing
...
Code Block | ||||
---|---|---|---|---|
| ||||
sudo nano /usr/local/FlashphonerWebCallServer/bin/webcallserver set-permissions sudo systemctl restart webcallserver |
Renewing the stream publishing after interruption
A separate UDP port is opened for every MPEG-TS publishing session to accept client connection (for SRT only) and receive media traffic. Due to security reasons, since build 5.2.1299, the stream will be stopped on server if client stops publishing (like WebRTC one), and publisher can't connect and send traffic to the same port. All the stream viewers will receive STREAM_STATUS.FAILED
in this case. A new REST API query should be used to renew the stream publishing, with the same name if necessary.
Publishers restriction by IP address
Since build 5.2.1314 it is possible to restrict client IP addresses which are allowed to publish MPEG-TS stream via UDP using REST API /mpegts/startup
query parameter
Code Block | ||||
---|---|---|---|---|
| ||||
{
"localStreamName":"mpegts-stream",
"transport":"udp",
"allowedList": [
"192.168.0.100",
"172.16.0.1/24"
]
} |
Since build 5.2.1485 MPEG-TS via SRT publishers may also be restricted
Code Block | ||||
---|---|---|---|---|
| ||||
{
"localStreamName":"mpegts-stream",
"transport":"srt",
"allowedList": [
"192.168.0.100",
"172.16.0.1/24"
]
} |
The list may contain both exact IP addresses and address masks. If REST API query contains a such list, only the clients with IP addresses matching the list can publish the stream.
H265 publishing
Since build 5.2.1577 it is possible to publish MPEG-TS H265+AAC stream. H265 codec should be set in mpegts_agent.sdp
file:
Code Block | ||
---|---|---|
| ||
v=0
o=- 1988962254 1988962254 IN IP4 0.0.0.0
c=IN IP4 0.0.0.0
t=0 0
a=sdplang:en
m=audio 1 RTP/AVP 102
a=rtpmap:102 mpeg4-generic/48000/2
a=sendonly
m=video 1 RTP/AVP 119
a=rtpmap:119 H265/90000
a=sendonly |
Since build 5.2.1598, WCS supports MPEG-TS stream publishing both in H264 and H265 codecs by default without SDP settings change.
H265 must also be added to supported codecs list
Code Block | ||
---|---|---|
| ||
codecs=opus,alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,h264,vp8,flv,mpv,h265 |
and to exclusion lists
Code Block | ||
---|---|---|
| ||
codecs_exclude_sip=mpeg4-generic,flv,mpv,h265
codecs_exclude_sip_rtmp=opus,g729,g722,mpeg4-generic,vp8,mpv,h265
codecs_exclude_sfu=alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,flv,mpv,h265 |
H265 publishing example using ffmpeg
Code Block | ||||
---|---|---|---|---|
| ||||
ffmpeg -re -i source.mp4 -c:v libx265 -c:a aac -ar 48000 -ac 2 -b:a 160k -bsf:v hevc_mp4toannexb -keyint_min 120 -profile:v main -preset veryfast -x265-params crf=23:bframes=0 -f mpegts "srt://test.flashphoner.com:31014" |
Warning |
---|
H265 will be transcoded to H264 or VP8 to play it from server! |
Known issues
1. When MPEG-TS stream publishing via UDP is stopped at server side via REST API query /mpegts/terminate
, publishing encoder still sends media data
...