...
It is recommended to set hyphenated profile names for convinuence.
Server restart is necessary to apply changes in cdn_profiles.yml
file.
Profile parameters
Parameter | Values available | Description |
---|---|---|
Audio parameters | ||
codec | opus mpeg4-generic speex | Audio codec to use |
bitrate | Depends on quality required and bandwith available | Audio 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 |
bitrate | Depends on quality required and bandwith available | Video bitrate, kbps |
width | Depends on quality required and bandwith available | Picture width |
height | Depends on quality required and bandwith available | Picture height |
codeImpl | FF OPENH264 | Video codec used: based on FFmpeg or OpenH.264 |
gop | Depends on quality required and bandwith available | Key frames frequency (GOP) |
fps | Depends on quality required and bandwith available | Frames frequency per second |
quality | Depends on quality required and bandwith available | Video quality |
preset | ultrafast superfast veryfast faster fast medium slow slower veryslow placebo | FFmpeg preset, ultrafast by default |
profile | Depends on quality required | FFmpeg profile, Baseline by default |
level | Depends on quality required | FFmpeg 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 |
| 200 – OK 400 - Bad Request 409 - Conflict 500 – Internal Server Error | Add transcoding profile | ||||||||
/cdn/profile/modify |
| 200 – OK 400 - Bad Request 404 - Not Found 500 – Internal Server Error | Change transcoding profile | ||||||||
/cdn/profile/print |
| 200 – OK 404 - Not Found 500 – Internal Server Error | Get the transcoding profiles list | ||||||||
/cdn/profile/remove |
| 200 – OK 404 - Not Found 500 – Internal Server Error | Remove transcoding profile |
Parameters
Parameter name | Description | Example |
---|---|---|
name | Имя профиля | -profile1 |
profile | Параметры профиля | { |
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 | ||||
---|---|---|---|---|
| ||||
{
"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 | ||||
---|---|---|---|---|
| ||||
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 | ||
---|---|---|
| ||
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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
-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 | ||
---|---|---|
| ||
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 |
|
| 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 |
| 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 |
role | Node role: ORIGIN, TRANSCODER or EDGE | ORIGIN |
...