Versions Compared

Key

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

...

2. Playback can start slightly earlier if start time is set, depending on closest key frame in the recording file.

...

REST hook for stream recording

...

Since build build 5.2.1012 it 1416 it is possible to record multiple streams to one file. Then streams can be extracted from this file and mixed by a special tool. Multiple streams can be recorded only to MP4 container (H264 + AAC). This feature is intended, for example, to record a video conference. In this case, unlike to MCU mixer, stream mixing works while recording file is post-processed, this allows to aquire a less of server resources during the conference itself.

Multiple stream recording is managed by REST API.

REST query must be HTTP/HTTPS POST query like this:

  • HTTP: http://streaming.flashphoner.com:8081/rest-api/multipleRecorder/startup
  • HTTPS: https://streaming.flashphoner.com:8444/rest-api/multipleRecorder/startup

Where:

  • streaming.flashphoner.com is WCS server address
  • 8081 is a standard WCS REST / HTTP port
  • 8444 is a standard WCS REST / HTTPS port
  • rest-api is mandatory prefix
  • /multipleRecorder/startup is REST method

REST methods and responses

...

REST query

...

Example of REST query

...

Example of REST response

...

Response states

...

Description

/multipleRecorder/startup

...

Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder://test-record"
}

409 - Conflict

500 - Internal error

...

Launch multiple streams recorder

...

Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder://test-record",
 "mediaSessionId": "866a9910-fbfe-11eb-aae4-6f99b0c80a3a"
}

...

404 - Not found

409 - Conflict

500 - Internal error

...

languagejs
themeRDark

...

receive an events about a certain stream recording starting or stopping. WCS sends to a backend server the REST hook /StreamEvent  

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/StreamEvent
OBJECT:
{
  "nodeId" : "d2hxbqNPE04vGeZ51NPhDuId6k3hUrBB@192.168.1.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.1.83:49977/192.168.1.39:8443-591009c4-e051-4722-b34d-71cf2ade3bed",
  "mediaSessionId" : "15de2290-4089-11ed-88fe-d78a87cf3386",
  "type" : "startedRecording",
  "payload" : {
    "fileName" : "stream-15de2290-4089-11ed-88fe-d78a87cf3386-8mv1of1o4fni58k0qdomu52kru.mp4"
  }
}

when stream recording is started and

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/StreamEvent
OBJECT:
{
  "nodeId" : "d2hxbqNPE04vGeZ51NPhDuId6k3hUrBB@192.168.1.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.1.83:49977/192.168.1.39:8443-591009c4-e051-4722-b34d-71cf2ade3bed",
  "mediaSessionId" : "15de2290-4089-11ed-88fe-d78a87cf3386",
  "type" : "stoppedRecording",
  "payload" : {
    "fileName" : "

...

stream-15de2290-4089-11ed-88fe-d78a87cf3386-8mv1of1o4fni58k0qdomu52kru.mp4"
  }

...

404 - Not found

500 - Internal error

...

}

when stream recording is stopped.

The StreamEvent method must be added to a backend application configuration when updating WCS from previous builds

...

Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder://test-record"
}

...

404 - Not found

500 - Internal error

...

Parametes

...

Parameter name

...

Description

...

Example

...

mediaSessionId

...

Stream mediasession Id

...

866a9910-fbfe-11eb-aae4-6f99b0c80a3a

...

Recording file name

Multiple streams recording file name is formed by template. In this case:

1. {streamName} parameter is set according to recorder URI, replacing all the characters not allowed to use in file system to underline.

2. {startTime}, {endTime} parameters cannot be set because they depend on stream timestamps, and we have a multiple streams with a different timestamps simultaneously. So it is recommended to use {startTimeMillis}, {endTimeMillis} parameters to add servers clock timestamps to file name.

For example, with the following template

Code Block
languagejs
themeRDark
stream_record_policy_template={streamName}-{startTime}-{startTimeMillis}-{endTime}-{endTimeMillis}

...

Code Block
languagejs
themeRDark

...

{
 "uri": "multi-recorder://test-record",
 "mediaSessionId": "866a9910-fbfe-11eb-aae4-6f99b0c80a3a"
}

...

404 - Not found

500 - Internal error

...

add app-rest-method defaultApp StreamEvent
add app-rest-method MyAppKey StreamEvent

Multiple stream recording to one file with subsequent mixing

Since build 5.2.1012 it is possible to record multiple streams to one file. Then streams can be extracted from this file and mixed by a special tool. Multiple streams can be recorded only to MP4 container (H264 + AAC). This feature is intended, for example, to record a video conference. In this case, unlike to MCU mixer, stream mixing works while recording file is post-processed, this allows to aquire a less of server resources during the conference itself.

Multiple stream recording is managed by REST API.

REST query must be HTTP/HTTPS POST query like this:

  • HTTP: http://streaming.flashphoner.com:8081/rest-api/multipleRecorder/startup
  • HTTPS: https://streaming.flashphoner.com:8444/rest-api/multipleRecorder/startup

Where:

  • streaming.flashphoner.com is WCS server address
  • 8081 is a standard WCS REST / HTTP port
  • 8444 is a standard WCS REST / HTTPS port
  • rest-api is mandatory prefix
  • /multipleRecorder/startup is REST method

REST methods and responses

REST query

Example of REST query

Example of REST response

Response states

Description

/multipleRecorder/startup


Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder://test-record"

...

will look as follows:

...


}

409 - Conflict

500 - Internal error


Launch multiple streams recorder

/multipleRecorder/add
Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder

...

://test-record",
 "mediaSessionId": "866a9910-fbfe-

...

11eb-

...

Here {startTime},  {endTime} are replaced by -1.

Multiple streams recording folder

By default, multiple streams recording files are stored in WCS_HOME/records forlder. Since build 5.2.1088, multiple streams recording folder can be set using the following parameter

Code Block
themeRDark
multi_record_dir=/usr/local/FlashphonerWebCallServer/records

This folder should be writalble, For example, if the folder is set to

Code Block
themeRDark
multi_record_dir=/opt/media

the folder access privilegies sholud be set as

Code Block
languagebash
themeRDark
sudo chmod o+w /opt/media

Multiple streams mixing tool

Only one stream can be played by default from multiple streams recording file. The streams should be mixed to view them all. The OfflineMP4Mixer tool should be used to mix, launching as follows:

Code Block
languagebash
themeRDark
cd /usr/local/FlashphonerWebCallServer/tools
./offline_mixer_tool.sh multi-recorder___test-record--1-1628821032180--1-1628821151750.mp4

Offline mixer settings should be defined in /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file. By default, the following settings are used:

Code Block
languagejs
themeRDark
{
  "hasVideo": "true",
  "hasAudio": "true",
  "mixerDisplayStreamName": true
}

A mixed file is placed to the same folder as original one, with _mixed suffix addition, for example

Code Block
themeRDark
multi-recorder___test-record--1-1628821032180--1-1628821151750_mixed.mp4

A picture sample from the mixed file

Image Removed

Getting tracks information from multiple recording file

Since build 5.2.1049 tracks information from multiple recording file may be extracted using multiple stream mixing tool. To do this, the tool should be launched as follows:

Code Block
languagebash
themeRDark
./offline_mixer_tool.sh --show-tracks-info ../records/multi-recorder___test-record.mp4

In this case, the tool will print tracks information in JSON form. See two participants room recording information example below:

...

languagejs
themeRDark
titleTwo participants track information example
collapsetrue

...

aae4-6f99b0c80a3a"
}

404 - Not found

409 - Conflict

500 - Internal error

Add the stream with mediaSessionId to the recorder
/multipleRecorder/find_all
Code Block
languagejs
themeRDark
[
  {
    "mediaSessionsId": [
      "866a9910-fbfe-11eb-aae4-6f99b0c80a3a",
      "9f1e2530-fbfe-11eb-9ec1-77172ac14d86",
      "a970d0a0-fbfe-11eb-8fcc-912807bab442"
    ],
    "uri": "multi-recorder://test-record",
    "fileName": "multi-recorder___test-record.mp4"
  }
]

404 - Not found

500 - Internal error

Find all recorders
/multipleRecorder/remove
Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder://test-record",
 "mediaSessionId": "866a9910-fbfe-11eb-aae4-6f99b0c80a3a"
}

404 - Not found

500 - Internal error

Remove stream with mediaSessionId from recorder
/multipleRecorder/terminate
Code Block
languagejs
themeRDark
{
 "uri": "multi-recorder://test-record"
}

404 - Not found

500 - Internal error

Stop multiple streams recorder

Parametes

Parameter name

Description

Example

uriRecorder URImulti-recorder://test-record

mediaSessionId

Stream mediasession Id

866a9910-fbfe-11eb-aae4-6f99b0c80a3a

filenameRecording file namemulti-recorder___test-record.mp4

Recording file name

Multiple streams recording file name is formed by template. In this case:

1. {streamName} parameter is set according to recorder URI, replacing all the characters not allowed to use in file system to underline.

2. {startTime}, {endTime} parameters cannot be set because they depend on stream timestamps, and we have a multiple streams with a different timestamps simultaneously. So it is recommended to use {startTimeMillis}, {endTimeMillis} parameters to add servers clock timestamps to file name.

For example, with the following template

Code Block
languagejs
themeRDark
stream_record_policy_template={streamName}-{startTime}-{startTimeMillis}-{endTime}-{endTimeMillis}

the file name for recorder with URI

Code Block
languagejs
themeRDark
"uri": "multi-recorder://test-record"

will look as follows:

Code Block
themeRDark
multi-recorder___test-record--1-1628821032180--1-1628821151750.mp4

Here {startTime},  {endTime} are replaced by -1.

Multiple streams recording folder

By default, multiple streams recording files are stored in WCS_HOME/records forlder. Since build 5.2.1088, multiple streams recording folder can be set using the following parameter

Code Block
themeRDark
multi_record_dir=/usr/local/FlashphonerWebCallServer/records

This folder should be writalble, For example, if the folder is set to

Code Block
themeRDark
multi_record_dir=/opt/media

the folder access privilegies sholud be set as

Code Block
languagebash
themeRDark
sudo chmod o+w /opt/media

Multiple streams mixing tool

Only one stream can be played by default from multiple streams recording file. The streams should be mixed to view them all. The OfflineMP4Mixer tool should be used to mix, launching as follows:

Code Block
languagebash
themeRDark
cd /usr/local/FlashphonerWebCallServer/tools
./offline_mixer_tool.sh multi-recorder___test-record--1-1628821032180--1-1628821151750.mp4

Offline mixer settings should be defined in /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file. By default, the following settings are used:

Code Block
languagejs
themeRDark
{
  "hasVideo": "true",
  "hasAudio": "true",
  "mixerDisplayStreamName": true
}

A mixed file is placed to the same folder as original one, with _mixed suffix addition, for example

Code Block
themeRDark
multi-recorder___test-record--1-1628821032180--1-1628821151750_mixed.mp4

A picture sample from the mixed file

Image Added

Getting tracks information from multiple recording file

Since build 5.2.1049 tracks information from multiple recording file may be extracted using multiple stream mixing tool. To do this, the tool should be launched as follows:

Code Block
languagebash
themeRDark
./offline_mixer_tool.sh --show-tracks-info ../records/multi-recorder___test-record.mp4

In this case, the tool will print tracks information in JSON form. See two participants room recording information example below:

Code Block
languagejs
themeRDark
titleTwo participants track information example
collapsetrue
[
  {
    "durationInMS": "37282",
    "trackEdits": [
      {
        "endInMs": "14",
        "type": "pause",
        "startInMs": "0"
      },
      {
        "endInMs": "37282",
        "type": "media",
        "startInMs": "14"
      }
    ],
    "channels": "2",
    "trackType": "AUDIO",
    "trackId": "1",
    "timescale": "44100",
    "streamName": "room-09f012-user1-e6ff",
    "trackCodec": "mp4a",
    "sampleRate": "44100",
    "mediaSessionId": "e6ff54e0-1c2a-11ec-90e8-79a2a32f3d9d"
  },
  {
    "durationInMS": "37336",
    "trackEdits": [
      {
        "endInMs": "3927437336",
        "type": "media",
        "startInMs": "215340"
      }
    ],
    "channelstrackType": "2VIDEO",
    "trackTypetrackId": "AUDIO0",
    "trackIdwidth": "3320",
    "timescale": "4410090000",
    "streamName": "room-09f012-user2user1-f746e6ff",
    "trackCodec": "mp4aavc1",
    "sampleRatemediaSessionId": "44100e6ff54e0-1c2a-11ec-90e8-79a2a32f3d9d",
    "mediaSessionIdheight": "f74633a1-1c2a-11ec-bba5-af8cf43275a8240"
  },
  {
    "durationInMS": "3930339274",
    "trackEdits": [
      {
        "endInMs": "21434100",
        "type": "pause",
        "startInMs": "0"
      },
      {
        "endInMs": "21534",
        "type": "pause",
        "startInMs": "100"
      },
      {
        "endInMs": "3930339274",
        "type": "media",
        "startInMs": "2143421534"
      }
    ],
    "trackTypechannels": "VIDEO2",
    "trackIdtrackType": "2AUDIO",
    "widthtrackId": "3203",
    "timescale": "9000044100",
    "streamName": "room-09f012-user2-f746",
    "trackCodec": "avc1"mp4a",
    "sampleRate": "44100",
    "mediaSessionId": "f74633a1-1c2a-11ec-bba5-af8cf43275a8",
   },
  {
    "heightdurationInMS": "39303",
    "240trackEdits": [
  }
]

Where:

  • durationInMS - track duration in milliseconds

  • trackType - track type: AUDIO or VIDEO

  • trackId - track Id
  • streamName - stream name containing this track
  • mediaSessionId - stream media session Id
  • timescale - track samples per second quantity
  • trackCodec - track codec
  • width, height - video track picture size by first key frame
  • channels - audio track channels count
  • sampleRate - audio track sample rate (usually equal to timescale parameter)
  • trackEdits - track timeline description

Track timeline is described as a set of segments according to MP4 'edit lists` atom content, with the following parameters:

  • startInMs - segment start time in milliseconds relative to file beginning
  • endInMs - segment end time in milliseconds relative to file beginning
  • type - segment type: mediadata (media) or pause (pause)

Any single track may be extracted from multiple recording file using ffmpeg or other MP4 editing tool.

Note that if a stream with the same name was added to multiple recorder, then removed from recorder and then added again, this stream will be repersented in the file as different tracks with subsequent track Ids, for example:

Code Block
languagejs
themeRDark
titleRe-added stream track information example example
collapsetrue
[
  {
    "durationInMS": "78978    {
        "endInMs": "21434",
        "type": "pause",
        "startInMs": "0"
      },
      {
        "endInMs": "39303",
        "type": "media",
        "startInMs": "21434"
      }
    ],
    "trackType": "VIDEO",
    "trackId": "2",
    "width": "320",
    "trackEditstimescale": ["90000",
      {
        "endInMs"streamName": "63050room-09f012-user2-f746",
        "typetrackCodec": "pauseavc1",
        "startInMsmediaSessionId": "0"
      },
      {
  f74633a1-1c2a-11ec-bba5-af8cf43275a8",
      "endInMsheight": "78978240",
        "type": "media",
        "startInMs": "63050"
      }
    ],
    "channels": "2",
    "trackType": "AUDIO",
    "trackId": "3",
    "timescale": "44100",
    "streamName": "test",
    "trackCodec": "mp4a",
    "sampleRate": "44100",
    "mediaSessionId": "fbbf5b50-20ee-11ec-bf06-ef6ec6048b2c"
  },
  {
    "durationInMS": "39708",
    }
]

Where:

  • durationInMS - track duration in milliseconds

  • trackType - track type: AUDIO or VIDEO

  • trackId - track Id
  • streamName - stream name containing this track
  • mediaSessionId - stream media session Id
  • timescale - track samples per second quantity
  • trackCodec - track codec
  • width, height - video track picture size by first key frame
  • channels - audio track channels count
  • sampleRate - audio track sample rate (usually equal to timescale parameter)
  • trackEdits - track timeline description

Track timeline is described as a set of segments according to MP4 'edit lists` atom content, with the following parameters:

  • startInMs - segment start time in milliseconds relative to file beginning
  • endInMs - segment end time in milliseconds relative to file beginning
  • type - segment type: mediadata (media) or pause (pause)

Any single track may be extracted from multiple recording file using ffmpeg or other MP4 editing tool.

Note that if a stream with the same name was added to multiple recorder, then removed from recorder and then added again, this stream will be repersented in the file as different tracks with subsequent track Ids, for example:

Code Block
languagejs
themeRDark
titleRe-added stream track information example example
collapsetrue
[
  {
    "durationInMS": "78978",
    "trackEdits": [
      {
        "endInMs": "2315063050",
        "type": "mediapause",
        "startInMs": "0"
      },
    ],  {
        "channelsendInMs": "278978",
        "trackTypetype": "AUDIOmedia",
        "trackIdstartInMs": "163050",
      }
    ],
    "channels": "2",
    "trackType": "AUDIO",
    "trackId": "3",
    "timescale": "44100",
    "streamName": "test",
    "trackCodec": "mp4a",
    "sampleRate": "44100",
    "mediaSessionId": "c7bc1460fbbf5b50-20ee-11ec-bf06-ef6ec6048b2c"
  },
  {
    "durationInMS": "3979139708",
    "trackEdits": [
      {
        "endInMs": "2323323150",
        "type": "media",
        "startInMs": "0"
      }
    ],
    "trackTypechannels": "VIDEO2",
    "trackIdtrackType": "0AUDIO",
    "widthtrackId": "6401",
    "timescale": "9000044100",
    "streamName": "test",
    "trackCodec": "avc1mp4a",
    "mediaSessionIdsampleRate": "c7bc1460-20ee-11ec-bf06-ef6ec6048b2c44100",
    "heightmediaSessionId": "360c7bc1460-20ee-11ec-bf06-ef6ec6048b2c"
  },
  {
    "durationInMS": "6305039791",
    "trackEdits": [
      {
        "endInMs": "3979123233",
        "type": "pausemedia",
        "startInMs": "0"
      },
      {
    ],
    "endInMstrackType": "50191VIDEO",
        "typetrackId": "media0",
        "startInMswidth": "39791"
      }
    ]640",
    "trackTypetimescale": "VIDEO90000",
    "trackIdstreamName": "2test",
    "widthtrackCodec": "640avc1",
    "timescalemediaSessionId": "90000c7bc1460-20ee-11ec-bf06-ef6ec6048b2c",
    "streamNameheight": "test360"
  },
  {
    "trackCodecdurationInMS": "avc163050",
    "mediaSessionIdtrackEdits": "ed3ebda0-20ee-11ec-bf06-ef6ec6048b2c",
[
     "height": "360"
  }
]

Multiple recording file handling script

When multiple stream recording is finished, a specila handling script is automatically launched as set by the following parameter

Code Block
themeRDark
on_multiple_record_hook_script=on_multiple_record_hook.sh

By default, script will launch offline_mixer_tool.sh, passing multiple streams recording file name to it.

Since build 5.2.1023, on_multiple_record_hook.sh script writes only file mixing result to log file /usr/local/FlashphonerWebCallServer/logs/multi-record.log, to decrease hard disk I/O load while offline mixing tool is working. A detailed logging mat=y be enabled if necessary by setting the following variable in the script

Code Block
languagebash
themeRDark
LOGGER_ENABLED=true

Multithreaded encoding while mixing multiple stream recordings

Since build 5.2.1089 multithreaded encoding can be enabled while mixing multiple stream recordings. To enable this feature, add the following parameter to /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file

Code Block
languagejs
themeRDark
{
  ...,
  "multithreading": true
}

Multiple stream recordings are mixed a twice faster when multithreaded encoding is enabled comparing to singe-threaded one.

Multiple recording data callback

Since build 5.2.1123 it is possible to send PORT query to a certain URL after multiple recording and mixing is finished. This allows to notify backend about file name to which chat room recording is mixed.

Callback URL should be set in /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file

Code Block
languagejs
themeRDark
{
  ...,
  "callbackUrl": "http://backend.url/multiRecorderCallback"
}

...

 {
        "endInMs": "39791",
        "type": "pause",
        "startInMs": "0"
      },
      {
        "endInMs": "50191",
        "type": "media",
        "startInMs": "39791"
      }
    ],
    "trackType": "VIDEO",
    "trackId": "2",
    "width": "640",
    "timescale": "90000",
    "streamName": "test",
    "trackCodec": "avc1",
    "mediaSessionId": "ed3ebda0-20ee-11ec-bf06-ef6ec6048b2c",
    "height": "360"
  }
]

Multiple recording file handling script

When multiple stream recording is finished, a specila handling script is automatically launched as set by the following parameter

Code Block
themeRDark
on_multiple_record_hook_script=on_multiple_record_hook.sh

...

By default, script will launch offline_mixer_tool.sh. Therefore, if  WCS build , passing multiple streams recording file name to it.

Since build 5.2.1123 is installed over a previous build, or if custom 1023, on_multiple_record_hook.sh is used, the script should be modified as follows:script writes only file mixing result to log file /usr/local/FlashphonerWebCallServer/logs/multi-record.log, to decrease hard disk I/O load while offline mixing tool is working. A detailed logging mat=y be enabled if necessary by setting the following variable in the script

Code Block
languagebash
themeRDark
titleon_multiple_record_hook.sh
collapsetrue
# This script copies a recorded stream to client/records
FILE_NAME=$1
CREATION_MODIFICATION_TIME=$2
DURATION_IN_MS=$3
RECORDER_URI=$4
WCS_HOME=LOGGER_ENABLED=true

Multithreaded encoding while mixing multiple stream recordings

Since build 5.2.1089 multithreaded encoding can be enabled while mixing multiple stream recordings. To enable this feature, add the following parameter to /usr/local/FlashphonerWebCallServer

...

/conf/offline_mixer

...

POST query contains a following JSON data:

Code Block
languagejs
themeRDark
POST /multiRecorderCallback HTTP/1.1
Content-Type: application/json
Content-Length: 463
Host: localhost
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.5 (java 1.5)
Accept-Encoding: gzip,deflate

{
  "multiRecorderCreationModificationTime":3724973476,
  "multiRecorderDurationInMS":44061,
  "multiRecorderFilePath":"/usr/local/FlashphonerWebCallServer/multirecords/stream-32c7edd7-37bf-4bf2-a58d-955679c5287e-mockLogin.mp4",
  "recorderUri":"multi-recorder://room-bace1f",
  "mixerParams":
  [
    {
      "path":"/usr/local/FlashphonerWebCallServer/multirecords/stream-32c7edd7-37bf-4bf2-a58d-955679c5287e-mockLogin_mixed.mp4",
      "durationInMs":44000,
      "creationModificationTime":3724973524
    }
  ]
}

Multiple recording file parameters:

  • multiRecorderCreationModificationTime - multiple recording file creation date and time
  • multiRecorderDurationInMS - multiple recording file duration in milliseconds
  • multiRecorderFilePath - multiple recording file path
  • recorderUri - multiple recording identifier, contains room name if RoomApi is used

Mixed file parameters:

  • path - mixed file path
  • durationInMs - mixed file duration in milliseconds
  • creationModificationTime - mixed file creation date and time

Minimal available disk space checking for multiple recordings mixing

Since build 5.2.1317 minimal available disk space checking is enabled for multiple recordings mixing. The mixing will not start or will be stopped when disk space becomes less then defined threshold value. The threshold is set by the following parameter in /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file.json file

Code Block
languagejs
themeRDark
{
  ...,
  "multithreading": true
}

Multiple stream recordings are mixed a twice faster when multithreaded encoding is enabled comparing to singe-threaded one.

Multiple recording data callback

Since build 5.2.1123 it is possible to send PORT query to a certain URL after multiple recording and mixing is finished. This allows to notify backend about file name to which chat room recording is mixed.

Callback URL should be set in /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file

Code Block
languagejs
themeRDark
{
  ...,
  "callbackUrl": "http://backend.url/multiRecorderCallback"
}

A recording data to send are passed via /usr/local/FlashphonerWebCallServer/bin/on_multiple_record_hook.sh script when launching offline_mixer_tool.sh. Therefore, if  WCS build 5.2.1123 is installed over a previous build, or if custom on_multiple_record_hook.sh is used, the script should be modified as follows:

Code Block
languagebash
themeRDark
titleon_multiple_record_hook.sh
collapsetrue
# This script copies a recorded stream to client/records
FILE_NAME=$1
CREATION_MODIFICATION_TIME=$2
DURATION_IN_MS=$3
RECORDER_URI=$4
WCS_HOME=/usr/local/FlashphonerWebCallServer
LOG_FILE=$WCS_HOME/logs/multi-record.log
MIXER_TOOL=$WCS_HOME/tools/offline_mixer_tool.sh
# Set LOGGER_ENABLED to true to enable mixing debug logging
LOGGER_ENABLED=false

echo "[$(date '+%Y-%m-%d %H:%M:%S')] Start mixing multiple recording file $FILE_NAME" >> $LOG_FILE

if $LOGGER_ENABLED; then
    bash $MIXER_TOOL $FILE_NAME $CREATION_MODIFICATION_TIME $DURATION_IN_MS $RECORDER_URI >> $LOG_FILE 2>&1
else
    bash $MIXER_TOOL $FILE_NAME $CREATION_MODIFICATION_TIME $DURATION_IN_MS $RECORDER_URI > /dev/null 2>&1
fi

CODE=$?
if [ "$CODE" -ne "0" ]; then
    if [ "$CODE" -eq "64" ]; then
        echo "ERROR: File to mix not found" >> $LOG_FILE
    elif [ "$CODE" -eq "65" ]; then
        echo "ERROR: Offline mixer config not found" >> $LOG_FILE
    else
	    echo "ERROR: Offline mixer tool error code: $CODE" >> $LOG_FILE
	fi
	exit $CODE
fi
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Multiple recording file $FILE_NAME is mixed successfully" >> $LOG_FILE
exit 0

POST query contains a following JSON data:

Code Block
languagejs
themeRDark
POST /multiRecorderCallback HTTP/1.1
Content-Type: application/json
Content-Length: 463
Host: localhost
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.5 (java 1.5)
Accept-Encoding: gzip,deflate

{
  "multiRecorderCreationModificationTime":3724973476,
  "multiRecorderDurationInMS":44061,
  "multiRecorderFilePath":"/usr/local/FlashphonerWebCallServer/multirecords/stream-32c7edd7-37bf-4bf2-a58d-955679c5287e-mockLogin.mp4",
  "recorderUri":"multi-recorder://room-bace1f",
  "mixerParams":
  [
    {
      "path":"/usr/local/FlashphonerWebCallServer/multirecords/stream-32c7edd7-37bf-4bf2-a58d-955679c5287e-mockLogin_mixed.mp4",
      "durationInMs":44000,
      "creationModificationTime":3724973524
    }
  ]
}

Multiple recording file parameters:

  • multiRecorderCreationModificationTime - multiple recording file creation date and time
  • multiRecorderDurationInMS - multiple recording file duration in milliseconds
  • multiRecorderFilePath - multiple recording file path
  • recorderUri - multiple recording identifier, contains room name if RoomApi is used

Mixed file parameters:

  • path - mixed file path
  • durationInMs - mixed file duration in milliseconds
  • creationModificationTime - mixed file creation date and time

Minimal available disk space checking for multiple recordings mixing

Since build 5.2.1317 minimal available disk space checking is enabled for multiple recordings mixing. The mixing will not start or will be stopped when disk space becomes less then defined threshold value. The threshold is set by the following parameter in /usr/local/FlashphonerWebCallServer/conf/offline_mixer.json file

Code Block
languagejs
themeRDark
{
  ...,
  "minAvailableSpace": "1G"
}

By default, disk space threshold is set to 1 Gb (same as for single stream recordings). If the treshold is reached while mixing is already working, the mixing will be stopped with keeping data already written to destination file. The file can be correctly played after that.

REST hook for multiple stream recording

Since build 5.2.1416 it is possible to receive an events about a certain stream is added or removed to/from multiple recorder. WCS sends to a backend server the REST hook /StreamEvent  

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/StreamEvent
OBJECT:
{
  "nodeId" : "d2hxbqNPE04vGeZ51NPhDuId6k3hUrBB@192.168.1.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.1.83:49977/192.168.1.39:8443-591009c4-e051-4722-b34d-71cf2ade3bed",
  "mediaSessionId" : "15de2290-4089-11ed-88fe-d78a87cf3386",
  "type" : "addedToMultiRecording",
  "payload" : {
    "fileName" : "stream-0389ff08-7e45-4f00-a579-9d253319cba4-mockLogin.mp4",
    "uri" : "multi-recorder://test-record"
  } 
}

when stream is added to a multiple recorder and

Code Block
languagejs
themeRDark
URL:http://localhost:8081/apps/EchoApp/StreamEvent
OBJECT:
{
  "nodeId" : "d2hxbqNPE04vGeZ51NPhDuId6k3hUrBB@192.168.1.39",
  "appKey" : "defaultApp",
  "sessionId" : "/192.168.1.83:49977/192.168.1.39:8443-591009c4-e051-4722-b34d-71cf2ade3bed",
  "mediaSessionId" : "15de2290-4089-11ed-88fe-d78a87cf3386",
  "type" : "removedFromMultiRecording",
  "payload" : {
    "fileName" : "stream-0389ff08-7e45-4f00-a579-9d253319cba4-mockLogin.mp4",
    "uri" : "multi-recorder://test-record"
  }
}

when stream is removed from multiple recorder.

The StreamEvent method must be added to a backend application configuration when updating WCS from previous builds

Code Block
languagejs
themeRDark
{
  ...,
  "minAvailableSpace": "1G"
}

...

add app-rest-method defaultApp StreamEvent
add app-rest-method MyAppKey StreamEvent

Known issues

1. Maximum length of file name in all actual Linux file systems is limited to 255 characters. When record file is created, its name will be trimmed to this limit including extension and part number if rotation is enabled.

...