Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Operation flowchart

1. Publisher sends REST API query /mpegts/startup 

...

Code Block
languagejs
themeRDark
{
  "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": 90000
1,
  "allowedList": []
}

UDP:

Code Block
languagejs
themeRDark
{
  "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": 1,
  "allowedList": 90000[]
}

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

Code Block
languagejs
themeRDark
{
  "localStreamName":"test",
  "transport":"srt",
  "hasAudio": true,
  "hasVideo": true
}
Code Block
languagejs
themeRDark
{
  "localMediaSessionId": "32ec1a8e-7df4-4484-9a95-e7eddc45c508",
  "localStreamName": "test",
  "uri": "srt://192.168.1.39:31014",
  "status": "CONNECTED",
  "hasAudio": truefalse,
  "hasVideo": truefalse,
  "record": false,
  "timeouttransport": 90000"SRT",
  "cdn": false,
  "timeout": 90000,
  "maxTimestampDiff": 90000 1,
  "allowedList": []
}

200 - OK

409 - Conflict

500 - Internal error


Start MPEG-TS publishing


/mpegts/find
Code Block
languagejs
themeRDark
{
  "localStreamName":"test",
  "uri": "srt://192.168.1.39:31014"
}
Code Block
languagejs
themeRDark
[
 {
  "localMediaSessionId": "32ec1a8e-7df4-4484-9a95-e7eddc45c508",
  "localStreamName": "test",
  "uri": "srt://192.168.1.39:31014",
  "status": "CONNECTEDPROCESSED_LOCAL",
  "hasAudio": truefalse,
  "hasVideo": truefalse,
  "record": false,
  "timeouttransport": 90000"SRT",
  "maxTimestampDiffcdn": 90000
 }
]false,
  "timeout": 90000,
  "maxTimestampDiff": 1,
  "allowedList": []
 }
]

200 – streams found

404 – streams not found

500 - Internal error

Find the MPEG-TS stream by criteria

/mpegts/find_all


Code Block
languagejs
themeRDark
[
 {
  "localMediaSessionId": "32ec1a8e-7df4-4484-9a95-e7eddc45c508",
  "localStreamName": "test",
  "uri": "srt://192.168.1.39:31014",
  "status": "CONNECTED",
  "hasAudio": true,
  "hasVideo": true,
  "record": false,
  "timeout": 90000,
  "maxTimestampDiff": 90000
 }
]

200 – streams found

404 – streams not found

500 - Internal error

Find all MPEG-TS streams

/mpegts/terminate

Code Block
languagejs
themeRDark
{
  "localStreamName":"test"
}

200 - stream stopped

404 - stream not found

500 - Internal error

Stop MPEG-TS stream

...

Name

Description

Example

localStreamNameName to set to the stream on servertest
transportTransport to usesrt
uriEndpoint URI to publish the streamudp://192.168.1.39:31014
localMediaSessionIdStream media session Id32ec1a8e-7df4-4484-9a95-e7eddc45c508
statusStream statusCONNECTED
hasAudioStream has audio tracktrue
hasVideoStream has video tracktrue
recordStream is recordingfalse
timeoutMaximum media data receiving timeout, ms90000
maxTimestampDiffMaximum stream timestamps difference, mss900001

allowedList

Client addresses list which are allowed to publish the stream

["192.168.1.0/24"] 

...

Since build 5.2.1314 it is possible to restrict client IP addresses whic which are allowed to publish MPEG-TS stream via UDP using REST API /mpegts/startup query parameter

Code Block
languagejs
themeRDark
{
  "localStreamName":"mpegts-stream",
  "transport":"udp",
  "allowedList": [
    "192.168.0.100",
    "172.16.0.1/24"
  ]
}

The list may contain both exact IP adresses and address masks. If REST API query contains a such list, only the clients with IP addresses matching the list can publish the stream.Since build 5.2.1485 MPEG-TS via SRT publishers may also be restricted

Code Block
languagejs
themeRDark
{
  "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
themeRDark
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
themeRDark
codecs=opus,alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,h264,vp8,flv,mpv,h265

and to exclusion lists

Code Block
themeRDark
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
languagebash
themeRDark
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

...