Versions Compared

Key

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

...

It is recommended to set hyphenated profile names for convinuence.

Server restart is necessary to apply changes in cdn_profiles.yml file.

Profile parameters

ParameterValues availableDescription
Audio parameters
codec

opus

mpeg4-generic

speex

Audio codec to use
bitrateDepends on quality required and bandwith availableAudio bitrate, bps
rate

8000

11025

12000

16000

22050

24000

32000

44100

48000

Audio sample rate, kHz
channels

1

2

Channels quantity: mono or stereo
Video parameters
codec

h264

vp8

Video codec to use
bitrateDepends on quality required and bandwith availableVideo bitrate, kbps
widthDepends on quality required and bandwith availablePicture width
heightDepends on quality required and bandwith availablePicture height
codeImpl

FF

OPENH264

Video codec used: based on FFmpeg or OpenH.264
gopDepends on quality required and bandwith availableKey frames frequency (GOP)
fpsDepends on quality required and bandwith availableFrames frequency per second
qualityDepends on quality required and bandwith availableVideo quality
preset

ultrafast

superfast

veryfast

faster

fast

medium

slow

slower

veryslow

placebo

FFmpeg preset, ultrafast by default
profileDepends on quality requiredFFmpeg profile, Baseline by default
levelDepends on quality requiredFFmpeg level, 3.1 by default

...

defines veryfast preset usage with Main profile and level 3.1

Picture aspect ratio preserving while stream transcoding by profile

...

Transcoding profile management using REST API

The specific REST API is used to manage transcoding profiles on the fly, without server restart

REST query should be HTTP/HTTPS POST request as follows:

  • HTTP: http://test.flashphoner.com:8081/rest-api/cdn/profile/print
  • HTTPS: https://test.flashphoner.com:8444/rest-api/cdn/profile/print

Where:

  • test.flashphoner.com - WCS server address
  • 8081 - standard REST / HTTP port of WCS server
  • 8444 - standard HTTPS port
  • rest-api - URL mandatory part
  • /cdn/profile/print - REST query used

REST queries should be sent to Edge server. Any profile changes are stored in memory and applied immediately, also they are written to cdn_profiles.yml file to use after server restart.

REST queries and response states

REST query

REST query body example

Response body example

Response states

Description

/cdn/profile/add

Code Block
languagejs
themeRDark
{
"name": "-profile1",
"profile": {
        "audio": {
            "type": "audio"
            "bitrate": 0, 
            "channels": 0, 
            "codec": "opus", 
            "rate": 48000, 
        }, 
        "video": {
            "type": "video", 
            "bitrate": 0, 
            "codec": "h264", 
            "codecImpl": "FF", 
            "fps": 30, 
            "gop": 90, 
            "height": 360, 
            "quality": 0, 
            "width": 640
        }
}
}





200 – OK

400 - Bad Request

409 - Conflict

500 – Internal Server Error

Add transcoding profile

/cdn/profile/modify
Code Block
languagejs
themeRDark
{
"name": "-profile1",
"profile": {
        "video": {
            "bitrate": 400, 
            "quality": 25
        }
}
}




200 – OK

400 - Bad Request

404 - Not Found

500 – Internal Server Error

Change transcoding profile
/cdn/profile/print
Code Block
languagejs
themeRDark
    "-240p": {
        "audio": {
            "bitrate": 0, 
            "channels": 0, 
            "codec": "opus", 
            "rate": 48000, 
            "type": "audio"
        }, 
        "video": {
            "bitrate": 0, 
            "codec": "h264", 
            "codecImpl": "FF", 
            "fps": 25, 
            "gop": 50, 
            "height": 240, 
            "preset": "veryfast", 
            "quality": 0, 
            "type": "video", 
            "width": 0
        }
    }, 
    "-480p": {
        "audio": {
            "bitrate": 0, 
            "channels": 0, 
            "codec": "opus", 
            "rate": 48000, 
            "type": "audio"
        }, 
        "video": {
            "bitrate": 0, 
            "codec": "h264", 
            "codecImpl": "FF", 
            "fps": 25, 
            "gop": 50, 
            "height": 480, 
            "preset": "veryfast", 
            "quality": 0, 
            "type": "video", 
            "width": 0
        }
    }

200 – OK

404 - Not Found

500 – Internal Server Error

Get the transcoding profiles list
/cdn/profile/remove
Code Block
languagejs
themeRDark
{
"name": "-profile1"
}




200 – OK

404 - Not Found

500 – Internal Server Error

Remove transcoding profile

Parameters

Parameter name

Description

Example

name

Имя профиля

-profile1

profile

Параметры профиля

{
"audio": {
"type": "audio"
"bitrate": 0,
"channels": 0,
"codec": "opus",
"rate": 48000,
},
"video": {
"type": "video",
"bitrate": 0,
"codec": "h264",
"codecImpl": "FF",
"fps": 30,
"gop": 90,
"height": 360,
"quality": 0,
"width": 640
}

Profile parameters should contain audio or video sections.

The mandatory profile parameters are:

  • audio:
    • bitrate
    • codec
    • rate
    • channels
  • video:
    • bitrate
    • codec
    • width
    • height
    • quality

If some of those parametes are omitted in profile creation query, they will be added to profile with 0 value for digital parameters and "" for string parameters, in this case default values will be applied.

The remaining parameters are optional and may be omitted in the profile:

  • video:
    • codecImpl
    • fps
    • gop
    • level
    • preset
    • profile

When modifying a profile, only parameters passed in REST query will be changed. To drop some of mandatory parameters to default value, or to remove optional parameter from profile, -1 should be passed, fro example:

Code Block
languagejs
themeRDark
{
"name": "-profile1",
"profile": {
        "video": {
            "bitrate": -1, 
            "codecImpl": -1
        }
}
}

Used profiles modification

If stream is played by the profile, this profile can be modified after stream playback finishes and publishing agent stops, i.e. near 1 minute after last stream subscriber disconnects.

When stream is transcoded on Edge server

Stream will be transcoded on Edge under the following conditions:

1. If server video codec priority is higher than profile video codec priority. For example, if the following profile is used

Code Block
languageyml
themeRDark
 profile1-opus-vp8:
  audio:
    codec : opus
    rate : opus48000
    ratechannels : 480002
  video:
    width : 320
    height : 180240
    gop : 9060
    fps : 30
    codec : h264

the stream will be transcoded to 320x240 (4:3).

...

 : vp8
    codecImpl : FF

and the following codec priority is set in server properties

Code Block
themeRDark
codecs=opus,...,h264,vp8,flv,mpv

then VP8 stream will be transcoded to H264 because this codec has a higher priority.

2. If there is no audio codec or sample rate from profile in subscribers' SDP, audio track will be transcoded to one of formats supported by subscriber.

Picture aspect ratio preserving while stream transcoding by profile

If picture aspect ratio preserving is enabled for all CDN nodes (by default), then stream aspect ratio as published to Origin node will be preserved while transcoding the stream on Transcoder node. For example, if the following profile (16:9) is applied  to 640x480 (4:3) stream

Code Block
languageyml
themeRDark
 profile3profile1:
  audio:
    codec : opus
    rate : 48000
  video:
    width : 320
    height : 180

When stream is transcoded on Edge server

Stream will be transcoded on Edge under the following conditions:

...


    gop : 90
    fps : 30
    codec : h264

the stream will be transcoded to 320x240 (4:3).

In this case, picture width may be omitted in transcoding profile, because width will be chosen according to picture aspect ratio. For example, the following profile is allowed

Code Block
languageyml
themeRDark
 -opus-vp8profile3:
  audio:
    codec : opus
    rate : 48000
    channels : 2
  video:
    width : 320
    height : 240
    gop : 60
    fps : 30
    codec : vp8 video:
    codecImplheight : FF

and the following codec priority is set in server properties

Code Block
themeRDark
codecs=opus,...,h264,vp8,flv,mpv

then VP8 stream will be transcoded to H264 because this codec has a higher priority.

...

180

Choosing a route for stream playback

...

REST query

REST query body example

REST response example

Response states

Description

/cdn/stream/show_routes

Code Block
languagejs
themeRDark
{
 "streamName":"test-webrtc-144"
}
Code Block
languagejs
themeRDark
{
    "REQUESTED-PROFILE": [
        "AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}",
        "VIDEO{width=256, height=144, gop=null, fps=null, bitrate=0, codec='h264', codecImpl='OPENH264', quality=null}"
    ],
    "1-PROFILE-192.168.1.220": [
        "AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}",
        "VIDEO{width=0, height=0, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='null', quality=null}",
        "VIDEO{width=320, height=180, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='FF', quality=null}",
        "VIDEO{width=256, height=144, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='OPENH264', quality=null}"
    ],
    "2-STREAM-192.168.1.220": [
        "AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}",
        "VIDEO{width=0, height=0, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='', quality=null}",
        "VIDEO{width=320, height=180, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='FF', quality=null}",
        "VIDEO{width=256, height=144, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='OPENH264', quality=null}"
    ],
    "3-NEW-TRANSCODER-192.168.1.220": [],
    "4-PROXY-192.168.1.219": [
        "AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}",
        "VIDEO{width=0, height=0, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='', quality=null}"
    ]
}

200 – OK

500 – Internal Server Error

Show CDN stream routes

Parameters

Description

Example

Stream name (including transcoding profile if necessary)

test-webrtc-144
Transcoding profile requested parameters
Profile requested parameters
REQUESTED-PROFILE
Audio parameters
AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}
Video parameters
VIDEO{width=256, height=144, gop=null, fps=null, bitrate=0, codec='h264', codecImpl='OPENH264', quality=null}
Transcoder stream parameters
Transcoding profiles used by Transcoder parameters
1-PROFILE-192.168.1.220
Stream pulled from Origin by Transcoder parameters
2-STREAM-192.168.1.220
Audio parameters
AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}
Video parameters (according to transcoding profiles used)
VIDEO{width=320, height=180, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='FF', quality=null}
Stream parameters that Transcoder can pull from Origin
3-NEW-TRANSCODER-192.168.1.220
Origin stream parameters
Stream published to Origin parameters
4-PROXY-192.168.1.219
Audio parameters
AUDIO{bitrate=0, codec='opus', rate=48000, channels=2}
Video parameters
VIDEO{width=0, height=0, gop=null, fps=null, bitrate=0, codec='H264', codecImpl='', quality=null}

...

REST query

REST query body example

REST response

Response states

Description

/cdn/show_nodes



Code Block
languagejs
themeRDark
[
    {
        "globalState": "ACTIVE", 
        "id": "192.168.1.64", 
        "processingState": "NEW_STREAMS_ALLOWED", 
        "role": "TRANSCODER"
    }, 
    {
        "globalState": "ACTIVE", 
        "id": "192.168.1.39", 
        "processingState": "NEW_STREAMS_ALLOWED", 
        "role": "ORIGIN"
    }
]

200 – OK

500 – Internal Server Error

Show CDN nodes state

Parameters

Parameter name

Description

Example

globalState

Node state: ACTIVE or PASSIVE

ACTIVE

id

Node address

192.168.1.64
processingState

If this node participates in stream playback route elections:

NEW_STREAMS_ALLOWED - participates

GROUP_CONNECTION_ALLOWED - not participates

NEW_STREAMS_ALLOWED
roleNode role: ORIGIN, TRANSCODER or EDGE
ORIGIN

...