Versions Compared

Key

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

...

Code Block
languagebash
themeRDark
codecs_exclude_cdn=opus,alaw,ulaw,g729,speex16,g722,telephone-event,flv

Choosing audio codecs foe stream forwarding through CDN

Forwarding audio through CDN

When forwarding audio through CDN, a set of available codecs is formed with theПри пробросе в CDN набор предлагаемых кодеков формируется с учетом

  • codec used to publish stream (as preferred), and
  • codecs supported on Origin and Edge servers (codecs setting in flashphoner.properties file) 

excluding codecs listed in codecs_exclude_cdn setting on Edge.

By default, if AAC is not excluded, the following AAC sample rates are defined in SDP: 48, 44.1, 32, 24, 22.05, 16, 12, 8 kHz.

For example, if Edge requests from Origin RTMP stteam published with AAC 48 kHZ, audio SDP will be following

Code Block
themeRDark
m=audio 31006 RTP/SAVPF 102 111 8 18 100 9 103 104 105 106 107 108 109 110
c=IN IP4 192.168.1.5
a=mid:1
a=rtpmap:102 mpeg4-generic/48000/2
a=rtpmap:111 opus/48000/2
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:100 speex/16000
a=rtpmap:9 G722/8000
a=rtpmap:103 mpeg4-generic/44100/2
a=rtpmap:104 mpeg4-generic/32000/2
a=rtpmap:105 mpeg4-generic/24000/2
a=rtpmap:106 mpeg4-generic/22050/2
a=rtpmap:107 mpeg4-generic/16000/2
a=rtpmap:108 mpeg4-generic/12000/2
a=rtpmap:109 mpeg4-generic/11025/2
a=rtpmap:110 mpeg4-generic/8000/2

PCMU is not available by default and will be enabled only when PCMA is excluded:

Code Block
languagebash
themeRDark
codecs_exclude_cdn=alaw

Custom SDP settings for RTMP (flash_handler_publish.sdp and flash_handler_play.sdp) does not affect SDP for sound forwarding through CDN.

With the default settings, transcoding will not occur, for example, in the following cases.:

  • WebRTC (Opus) stream published on Origin is played as WebRTC on Edge (Opus)
  • RTMP (AAC, any of sample rates listed above) stream published on Origin is played as RTMP on Edge (AAC with the same sample rate without resampling)
  • RTMP (Speex) stream published on Origin is played as RTMP on Edge (Speex)

If there is no codec used to publish a stream in the subscribers codecs set, then transcoding will be on Edge server:

  • WebRTC (Opus) stream published on Origin is played as RTMP on Edge (AAC): Opus-AAC transcoding on Edge
  • RTMP (AAC stream published on Origin is played as WebRTC on Edge (Opus): AAC-Opus transcoding on Edge
  • RTMP (Speex) stream published on Origin is played as WebRTC on Edge (Opus): Speex-Opus transcoding on Edge
  • RTMP (Speex) stream published on Origin is played as RTMP on Edge (AAC): Speex-AAC transcoding on Edge

If the subscribers codecs set includes no only AAC, then Speex for example may be used to playback RTMP as RTMP without transcoding.

Image Added

If the subscribers codecs set is limited to AAC only (flash_handler_play.sdp on Edge includes AAC only), then transcoding will be on Edge if another codec is used to publish RTMP stream:

Image Added

To exclude codecs while stream forwarding trough CDN, to escape transcoding on Edge server,codecs_exclude_cdn setting should be used on Edge. Then the only remaining codec will be used to forward a stream trough CDN, and if stream is published with another codec transcoding will be on Origin server.

For example, if supposed to be connected to Edge

1. RTMP subscribers with AAC only: all the codecs should be excluded except mpeg4-generic:

Code Block
languagebash
themeRDark
codecs_exclude_cdn=opus,alaw,ulaw,g729,speex16,g722,telephone-event,flv

Image Added

2. WebRTC subscribers with Opus only:  all the codecs should be excluded except opus:

Code Block
languagebash
themeRDark
codecs_exclude_cdn=mpeg4-generic,alaw,ulaw,g729,speex16,g722,telephone-event,flv

Image Added

Custom SDP setting to publish and play RTMP stream in CDN

flash_handler_publish.sdp

flash_handler_publish.sdp is used as publish SDP when subscriber connects to stream before WCS get audio and video from publishing client (i.e. before the real codec used by publisher is known).

In this case codecs priority will be determined in order set in flash_handler_publish.sdp. If there is no flash_handler_publish.sdp, then the default priority audio codec will be Speex.

For example, with default settings (without flash_handler_publish.sdp), when RTMP (AAC) stream published on Origin is played as WebRTC (Opus) on Edge through CDN

  • if subscriber connects after receiving audio from publisher (i.e. it is known that AAC is used): AAC-Opus transcoding on Edge
  • if subscriber connects before receiving audio from publisher (i.e. default Speex is used): AAC-Speex transcoding on Origin and Speex-Opus transcoding on Edge

If Origin has flash_handler_publish.sdp, in which AAC is set as first for example, then AAC will be used including the case when subscriber connects before receiving audio from publisher. Thus, if publication codec is known in advance then additional transcoding can be escaped by setting a codec in flash_handler_publish.sdp.

flash_handler_publish.sdp is not used to restrict publication codecs: if any codec is excluded from flash_handler_publish.sdp, it can still be used for publishing.

flash_handler_play.sdp

flash_handler_play.sdp is used for subscriber SDP only, and not affect codecs restrictions when frowarding stream through CDN. If some code is excluded from flash_handler_play.sdp, it will not be used to play RTMP stream by subscriber.

Choosing audio codec to play a streamВыбор кодека при воспроизведении потока

If there is a codec used to publish the stream in subscrbers codecs set then this codec will be used to play the stream (regardless of its priority). Otherwise, the subscribers priority codec will be used for playback, and transcoding will occur.

Quick manual on testing

1. For testing we use:

...