CDN 2.7¶
Overview¶
CDN 2.7 implements the following features in addition to previous versions:
- a separate Recorder server to record a streams published to CDN Origin servers
Recorder CDN nodes¶
Since WCS build 5.2.2173, a separate Recorder node may be added to CDN
This node pulls a streams published on Origin servers according to a filter rules and records them. A streams may be transcoded by a profile defined. At this point, a Recorder node seems like Edge for the rest of CDN nodes.
Warning
It is strongly recommended to use a fast SSD storage to record a lot of CDN streams
Streams filtering¶
By default, no streams are recorded. A special configuration file /usr/local/FlashphonerWebCallServer/conf/cdn_recorder_trap.json
is needed to record anything. This prevents a possible inner CDN channels and server overload.
A simplest configuration to allow all the CDN streams recording (this is not recommended for production use)
CDN streams may be filtered by stream name, Origin domain name or IP address, for example
{
"streams":
[
{
"streamName": "test.*",
"serverNames": [ "123.mycooldomain" ],
"profile": ""
},
{
"streamName": "web.*",
"serverIps": [ "172.16.1.0/16" ],
"profile": "720p"
},
{
"streamName": "s.*",
"serverIps": [ "172.16.1.39", "123.mylocaldomain" ]
}
],
"defaultProfile" : "360p"
}
Where
streamName
- stream name mask to recordserverNames
- a list of Origin server domain names to record a streams published on themserverIps
- a list of Origin server IP addresses or masks to record a streams published on themprofile
- a profile to transcode streams before recordingdefaultProfile
- a default transcoding profile to use if profile is not defined for the filter
The cdn_recorder_trap.json
file may be changed without WCS restarting, the changes will be applied on the fly. In this case:
- if some stream is recording by a some rule and it still conforms to the rule changed, the stream recording continues
- if some stream is recording by a some rule and it does not conform to the rule changed, the stream recording stops
- if some stream transcoding profile is changed, the stream recording stops and starts againg with a new profile
Use the following empty configuration to stop all the recordings on the node temporary
If cdn_recorder_trap.json
becomes invalid after edition, the last valid configuration is stored to cdn_recorder_trap.json.backup
file and streams recording continues.
Streams transcoding¶
It may be necessary to reduce a CDN streams resolution and bitrate before recording if streams are recorded for monitoring purposes. In this case, the profiles to transcode should be described in /usr/local/FlashphonerWebCallServer/conf/cdn_profiles.yml
file on Recorder node, for example
profiles:
-240p:
audio:
codec: mpeg4-generic
rate: 44100
channels: 1
groupId: audio
video:
width: 0
height: 240
bitrate: 500
codec: h264
gop: 60
fps: 30
audioGroupId: audio
-480p:
audio:
codec: mpeg4-generic
rate: 44100
channels: 1
groupId: audio
video:
width: 0
height: 480
bitrate: 700
codec: h264
gop: 60
fps: 30
audioGroupId: audio
The Recorder node will request a stream to record via Transcoder node by profile set in cdn_recorder_trap.json
file (see above). The stream will not be recorded if no transcoders are available in the CDN.
The following parameter may be used on Recorder node if no Transcoder nodes configured at all in the CDN
But this should be avoided in production to prevent Origin node overload.
Recording configuration¶
By default, stream recording files are named by the {streamName}-{startTime}-{endTime}
template, for example
-rw-rw-r-- 1 flashphoner flashphoner 42902738 Jan 24 03:25 fptest-480p-4069687945602-4069688261635.mp4
-rw-rw-r-- 1 flashphoner flashphoner 20640553 Jan 24 03:28 fptest-480p-4069688301602-4069688439669.mp4
-rw-rw-r-- 1 flashphoner flashphoner 24490079 Jan 24 03:23 test-1860699141421-1860699318669.mp4
-rw-rw-r-- 1 flashphoner flashphoner 25429162 Jan 24 03:28 test-1860699462631-1860699642985.mp4
All the stream recording settings are applied as for usual stream recording.
Recording configuration management by REST API¶
Streams recording configuration on Recorder node may bechanged using REST API queries to the Recorder:
- add a new filter to
cdn_recorder_trap.json
- show current filters in
cdn_recorder_trap.json
- show active recordings
- remove a filter from
cdn_recorder_trap.json
REST query should be HTTP/HTTPS POST request as follows:
- HTTP:
http://test.flashphoner.com:8081/rest-api/cdn/recorder/trap/show
- HTTPS:
https://test.flashphoner.com:8444/rest-api/cdn/recorder/trap/show
Where:
test.flashphoner.com
- WCS server address8081
- a standard WCS REST / HTTP port8444
- a standard WCS HTTPS portrest-api
- mandatory part of URL/cdn/recorder/trap/show
- REST query used
/cdn/recorder/trap/add¶
Add stream recordings filter to cdn_recorder_trap.json
file
Request example¶
POST /rest-api/cdn/recorder/trap/add HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{
"streamName": "stream1"
}
Response example¶
Return codes¶
Code | Reason |
---|---|
200 | OK |
400 | Bad request |
500 | Internal server error |
/cdn/recorder/trap/show¶
Show stream recording filters available in cdn_recorder_trap.json
file
Request example¶
Response example¶
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
{
"streams": [
{
"streamName": "stream.*",
"id": "aa5498dd91e312ff5f88e7eb26d0c019"
}
],
"defaultProfile": ""
}
Return codes¶
Code | Reason |
---|---|
200 | OK |
404 | Not found |
/cdn/recorder/trap/remove¶
Remove stream recordings filter from cdn_recorder_trap.json
file by identifier. The identifier is displayed by /cdn/recorder/trap/show query.
Request example¶
POST /rest-api/cdn/recorder/trap/remove HTTP/1.1
Host: localhost:8081
Content-Type: application/json
{
"id": "aa5498dd91e312ff5f88e7eb26d0c019"
}
Response example¶
Return codes¶
Code | Reason |
---|---|
200 | OK |
404 | Not found |
/cdn/recorder/trap/show_active¶
Show current stream recordings
Request example¶
POST /rest-api/cdn/recorder/show_active HTTP/1.1
Host: localhost:8081
Content-Type: application/json
Response example¶
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
[
"web1-720p 172.16.1.233",
"web2-720p 172.16.1.234",
"s1-360p 172.16.1.39",
"s2-360p 172.16.1.39"
]
Return codes¶
Code | Reason |
---|---|
200 | OK |
404 | Not found |
Backward compatibility¶
- Recorder node seems like Edge server for Origin and Transcoder servers of previous CDN versions