StartRecord
https://cloudrecord-api.zego.im/
Call this API to start cloud recording.
After developers successfully call the StartRecord API, the cloud recording service will record audio and video streams and whiteboards in the room according to the configured recording parameters.
- Each recording task has a maximum duration of 24 hours. After 24 hours, the recording task will automatically stop recording.
- ZEGOCLOUD recommends that you call the StopRecord method to stop recording for each recording task to avoid incurring additional costs from continuous recording.
Request
Query Parameters
Possible values: [StartRecord]
API prototype parameter
https://cloudrecord-api.zego.im?Action=StartRecord
ð¡Common parameter. Application ID, a unique credential assigned by ZEGOCLOUD. You can obtain it from the ZEGOCLOUD Console.
ð¡Common parameter. A 16-character hexadecimal random string (hex encoding of an 8-byte random number). For the generation algorithm, refer to Signature Example.
ð¡Common parameter. Current Unix timestamp in seconds. For the generation algorithm, refer to Signature Example. A maximum error of 10 minutes is allowed.
Possible values: [2.0]
Default value: 2.0
ð¡Common parameter. Signature version number.
ð¡Common parameter. Signature used to verify the legitimacy of the request. Please refer to Signature Mechanism for generation.
- application/json
Body
required
FillBlankandMaxIdleTimehave different scopes:FillBlank: Applies to the stream itself. As long as the recording task is still in progress, afterFillBlankis set to true, if the stream is in an interrupted state, it will continue to record with blank filling. At this time, the stream is still in an interrupted state and does not affect the determination of whether there are streams in the room.MaxIdleTime: Applies to the entire recording task state. When the duration without streams in the room exceedsMaxIdleTime, the entire recording task will be terminated.
- In stream mixing recording mode, if
StreamTypeis 1, it means only audio is recorded, and whiteboards cannot be recorded at this time. - 1: Single stream recording
- 2: Stream mixing recording
- 1: Record audio only
- 2: Record video only
- 3: Record audio and video (audio and video files merged) (default)
- 4: Record audio and video (audio and video files separated)
- Array[
- ]
- true: When a user's stream is interrupted, blank filling will be automatic. The effect of automatic blank filling varies depending on the recording mode.
-
Single stream recording: Only audio is filled with blanks.
Note
If the publishing end only publishes video streams, or the recording media stream type is video only, blank filling is not possible.
During the interruption, the server will supplement the audio with silent frames until the stream is published again in the room using the same stream ID. Finally, the same recording file will retain normal stream content and silent frames.
-
Stream mixing recording: During the interruption, the video will stay on the last frame (default) or display the stream view background image. In addition, if there is no audio content in the mixed stream, the server will supplement silent frames until the stream is published again in the room using the same stream ID. Finally, the same recording file will retain normal stream content, blank filling frames, and silent frames (if any). If you need to use a stream view background image for blank filling, please refer to the DefaultMixStreamBackgroundImage and BackgroundImage parameter descriptions. Setting the stream view background image only takes effect when performing stream mixing recording (i.e., RecordMode is 2).
-
- false: No blank filling when the user's stream is interrupted. In single stream recording mode, a new recording file will be generated the next time the user publishes the stream again. In stream mixing recording mode, there will only be one recording file, and no new recording file will be generated when the user publishes the stream again.
- Cloud recording automatically stops due to timeout when there are no streams in the room. See the definition of MaxIdleTime.
- Actively stop cloud recording.
- 1: Fill with last frame (default)
- 2: Fill with specified color
- 3: Do not fill frames
- Mini program clients only support filling with the last frame and do not support filling with a specified color or not filling frames.
- Web clients only support filling with black and do not support filling with the last frame, filling with other colors, or not filling frames.
- 1: Record audio frames in muted state (default)
- 2: Do not record audio frames in muted state
- true: Record whiteboard
- false: Do not record whiteboard (default)
- Array[
- If you want to record the whiteboard immediately after starting recording, you must specify the whiteboard ID.
- If you want to start recording without recording the whiteboard first, you can omit this parameter and call the Update whiteboard API to specify the whiteboard ID when you need to record the whiteboard.
- true: Record animated PPT, supports recording animation effects and videos in PPT.
- false: Do not record animated PPT. Animation effects and videos in PPT will not be recorded.
- ]
- 1: Custom layout, MixInputList must be specified
- 2: (Default) Equal division layout
- 3: Horizontal layout
- 4: Vertical layout
- 5: Floating layout
- Array[
- 1: Audio and video (default)
- 2: Whiteboard
- 1: Crop mode. In this mode, priority is given to ensuring the view is filled. After the original video is scaled proportionally to fill the view, content exceeding the view on all sides will be cropped. (Default)
- 2: Scale mode. In this mode, priority is given to ensuring the integrity of the original video. After the original video is scaled proportionally to fill the view, black borders will be added on all sides.
- It is recommended that the background image size matches the set stream view size. If the two are inconsistent, the background image will be stretched or compressed to fill the entire view.
- Background image format supports JPG and PNG, size cannot exceed 5MB. If the background image download fails, the setting will not take effect.
- URL supports HTTP and HTTPS protocols.
- ]
- 1: Crop mode. In this mode, priority is given to ensuring the view is filled. After the original video is scaled proportionally to fill the view, content exceeding the view on all sides will be cropped. (Default)
- 2: Scale mode. In this mode, priority is given to ensuring the integrity of the original video. After the original video is scaled proportionally to fill the view, black borders will be added on all sides.
- It is recommended that the background image resolution matches the output video resolution. If the two resolutions are inconsistent, the background image will be stretched or compressed to fill the entire view.
- Background image format supports JPG and PNG, size cannot exceed 5MB. If the background image download fails, the setting will not take effect.
- URL supports HTTP and HTTPS protocols.
- It is recommended that the watermark image size matches the set watermark layout size. If the two are inconsistent, the watermark image will be stretched to fill the watermark layout position.
- Watermark image format supports JPG and PNG, size cannot exceed 5MB. If the watermark image download fails, the setting will not take effect.
- URL supports HTTP and HTTPS protocols.
- In custom layout, if the BackgroundImage parameter is set for a specified stream ID, BackgroundImage will be displayed with priority.
- It is recommended that the background image size matches the set stream view size. If the two are inconsistent, the background image will be stretched or compressed to fill the entire view.
- Background image format supports JPG and PNG, size cannot exceed 5MB. If the background image download fails, the setting will not take effect.
- URL supports HTTP and HTTPS protocols.
- true: Start recording immediately after the recording task is started.
- false: After the recording task is started, wait for streams to be published in the room before starting recording.
- true: After the recording task is started, record the sound wave information of all current streams every 1 second.
- false: After the recording task is started, do not record sound wave information.
- Array[
- 0: Default type
- 1: Audio
- 2: Video
- 3: Audio and video
- ]
- TaskId_RoomId_UserId_StreamId_Type_UTC (single stream recording)
- Taskid_RoomId_MixOutputStreamId_Type_UTC (stream mixing recording)
- Taskid_Roomid_whiteboard_Type_UTC (single stream recording with whiteboard)
- MixOutputStreamId: Specified in MixConfig. "- whiteboard: Fixed, cannot be modified."
- 1: Amazon S3
- 2: Alibaba Cloud OSS
- 3: Tencent Cloud COS
- 4: Qiniu Cloud Kodo
- 5: Alibaba Cloud VOD
- 6: Tencent Cloud VOD
- 7: Huawei Cloud OBS
- 8: Google Cloud Storage
- 9: China Mobile Cloud EOS
- 10: Storage service provider using S3 protocol. You need to fill in the StorageParams property parameter EndPoint.
- When
Vendoris set to 1, 2, 3, 4, 7, 9, or 10,Region,Bucket,AccessKeyId, andAccessKeySecretare required. - When
Vendoris set to 5,AlibabaCloudVodParamsis required. Currently only supports uploading MP4 and FLV format files. - When
Vendoris set to 6,TencentCloudVodParamsis required. Currently only supports uploading MP4, FLV, JPG, and MP3 format files. - When
Vendoris set to 8,Bucket,AccessKeyId, andAccessKeySecretare required. - When
Vendoris set to 10,BucketandEndPointare required.
Room ID to be recorded.
RecordInputParams objectrequired
Note
Possible values: [1, 2]
Recording mode.
Possible values: [1, 2, 3, 4]
Default value: 3
Recording media stream type, only applicable to audio and video streams. Whiteboards only record video.
Task ID of the recording request initiated by the user. If a recording task with the specified ClientTaskId already exists, the response parameter TaskId will return the existing recording task ID; otherwise, the server will create a new recording task and the response parameter TaskId will return the new recording task ID.
RecordStreamList object[]
Stream ID to be recorded.
Default value: false
Whether to automatically fill blanks when the stream is interrupted. Default is false, i.e., no blank filling.
There are two possible timings for interruption blank filling:
FillFrame object
Possible values: [1, 2, 3]
Default value: 1
Frame filling mode.
Note
Regarding FrameFillMode:
Valid when FrameFillMode is set to 2, used to specify the fill color. Default is black. The first three bytes are RGB color values, and the fourth byte is fixed at 0, i.e., 0xRRGGBB00.
Possible values: [1, 2]
Default value: 1
Specifies whether to record audio frame data in muted state. Only takes effect when single stream recording, recording audio only, and output file format is mp3.
"Silence duration threshold for automatic recording file splitting, in seconds."
"During recording, if the silence duration is greater than or equal to this threshold, different recording files will be generated before and after this silence period."
"Only takes effect when single stream recording, recording audio only, output file format is mp3, and RecordMuteAudio is 2."
"When specified as 0, splitting occurs upon encountering silence. When not specified or specified as a negative number, no splitting occurs."
Default value: false
Whether to record whiteboard.
When this parameter is true, the Whiteboard parameter is required.
Whiteboard object[]
Aspect ratio of the original whiteboard (width).
Aspect ratio of the original whiteboard (height).
Default value: 1280
Resolution width of the output video for single stream whiteboard recording. Default is 1280.
Default value: 720
Resolution height of the output video for single stream whiteboard recording. Default is 720.
ID of the whiteboard to be recorded.
Whiteboard background color. Default is white. The first three bytes are RGB color values, and the fourth byte is fixed at 0, i.e., 0xRRGGBB00.
Default value: false
Whether to record animated PPT. Default is false.
Note
Before using the animated PPT recording feature, please contact ZEGOCLOUD sales to enable it for a fee. Otherwise, setting the
IsPPTAnimationandPPTAnimationFpsparameters will have no effect.
Possible values: >= 1 and <= 30
Default value: 15
Frame rate for recording animated PPT. Default is 15, valid range is [1,30].
Possible values: >= 5 and <= 86400
Default value: 30
"How long after there are no streams or whiteboards in the room to automatically stop cloud recording, in seconds. Default is 30 seconds. This value must be greater than or equal to 5 and less than or equal to 86400 (24 hours)."
Note
This parameter only takes effect when there are no streams or whiteboards in the room.
Possible values: >= 300 and <= 86400
Default value: 86400
Maximum recording task duration. Recording automatically ends when the duration reaches this value, in seconds. Default is 86400 seconds (24 hours). This value must be greater than or equal to 300 and less than or equal to 86400 (24 hours).
Note
The maximum recording duration limit supports increasing to 48 hours. If you need to adjust the maximum recording duration, please contact ZEGOCLOUD Technical Support.
MixConfig object
Possible values: [1, 2, 3, 4, 5]
Default value: 2
Layout mode.
MixInputList object[]
Specifies the ID of the stream to be recorded in this view.
If not specified, recording will be done in the order in which streams join the room.
Possible values: [1, 2]
Default value: 1
Type of content displayed in this view.
Type 2 is only valid when whiteboard recording is enabled. Only one view can be set as whiteboard. Setting two or more will return an error.
Possible values: >= 0 and <= 1920
Y-axis coordinate of the upper left corner of this view on the canvas, value range [0, 1920].
Possible values: >= 0 and <= 1920
X-axis coordinate of the upper left corner of this view on the canvas, value range [0, 1920].
Possible values: >= 0 and <= 1920
Y-axis coordinate of the lower right corner of this view on the canvas, value range [0, 1920].
Possible values: >= 0 and <= 1920
X-axis coordinate of the lower right corner of this view on the canvas, value range [0, 1920].
Layer priority of this view. When two views overlap, the one with the larger value is displayed on top.
Possible values: [1, 2]
Default value: 1
How to handle when the actual video stream aspect ratio is inconsistent with the view.
URL address of the stream view background image. Only takes effect when the StreamId parameter is specified. This background image will be displayed when the stream specified in custom layout does not exist or is interrupted.
Possible values: [1, 2]
Default value: 1
(Applicable when MixMode in MixConfig is not 1, i.e., not custom layout)
How to handle when the actual video stream aspect ratio is inconsistent with the view.
Note
To learn about
FillModeapplicable to custom layout, please refer tomixinputlist.FillMode.
Specifies the stream ID for mixed stream output, which will be part of OutputFileRule.
MixOutputVideoConfig object
Possible values: <= 1920
"Resolution width of the output video, in pixels."
"Width must be less than or equal to 1920, and the product of Width and Height cannot exceed 1920 * 1080, otherwise an error will be returned."
Possible values: <= 1920
"Resolution height of the output video, in pixels."
"Height must be less than or equal to 1920, and the product of Width and Height cannot exceed 1920 * 1080, otherwise an error will be returned."
Possible values: >= 5 and <= 30
Default value: 15
Output video frame rate. Default is 15, valid range [5,30].
"Output video bitrate, in bps. For example, to set the bitrate to 1.5 Mbps, you need to set this parameter to 1500*1000, which is 1500000."
MixOutputAudioConfig object
Default value: 48000
Audio bitrate. Default is 48000 bps.
Recording background color. Default is black. The first three bytes are RGB color values, and the fourth byte is fixed at 0, i.e., 0xRRGGBB00.
URL address of the video canvas background image.
When MixMode is set to 3, 4, or 5, used to specify the stream ID to display in the large view.
URL address of the watermark image.
MixOutputWatermarkImageConfig object
Possible values: >= 0 and <= 1920
X-axis coordinate of the upper left corner of the watermark on the canvas, value range [0, 1920], cannot exceed the value of Right and the width of the canvas.
Possible values: >= 0 and <= 1920
Y-axis coordinate of the upper left corner of the watermark on the canvas, value range [0, 1920], cannot exceed the value of Bottom and the height of the canvas.
Possible values: >= 0 and <= 1920
X-axis coordinate of the lower right corner of the watermark on the canvas, value range [0, 1920], cannot exceed the width of the canvas.
Possible values: >= 0 and <= 1920
Y-axis coordinate of the lower right corner of the watermark on the canvas, value range [0, 1920], cannot exceed the height of the canvas.
URL address of the default background image for stream view. When the FillBlank parameter is true and FrameFillMode = 3, this background image will be displayed when the specified stream does not exist or is interrupted, and the recording mode is stream mixing recording.
Default value: false
Whether to start recording immediately after the recording task is started. Default is false, which means recording starts after streams are published in the room.
MixOutputWatermarkTimestampConfig object
Possible values: >= 12 and <= 100
Font size, value range [12, 100], in px.
Default value: false
Whether to record sound wave information after the recording task is started. Default is false.
Sound wave information will be written to a separate file in JSON format. The file name is the same as the recording file name with a .sw suffix. After the recording task ends, it will be uploaded to the specified cloud storage location together with the recording file.
Possible values: [0, 1]
Default value: 0
"Sound wave information type. This parameter only takes effect when RecordSoundWave is true."
"- 0: Record stream ID information (default). Example: {\"time\":10, \"sound_wave\":[{\"stream_id\":\"s1\", \"volume\":0}]}"
"- 1: Record user ID information. Example: {\"time\":10, \"sound_wave\":[{\"user_id\":\"u1\", \"volume\":0}]}"
StreamConfigList object[]
Stream ID. If StreamId is empty, it indicates setting the default value of the parameter. Other streams that do not appear in StreamConfigList will use the parameter default value.
Possible values: [0, 1, 2, 3]
Stream recording type. Only takes effect when StreamType in RecordInputParams equals 3 or 4.
"Timeout for waiting for input streams, in milliseconds. During this period, the ZEGOCLOUD server waits to obtain input streams before starting stream mixing. If the timeout is reached and no input stream is received, stream mixing will start automatically."
RecordOutputParams object
Possible values: [mp4, flv, hls, jpg, mp3]
Default value: mp4
"Specifies the format of the recording file. Default is "mp4". Currently supports "mp4", "flv", "hls", "jpg", and "mp3". If recording "mp4" or "flv" and StreamType is set to 4, the generated audio file format is aac."
Note
When the stream is VP8 encoded and the recording file format is "mp4", please contact ZEGOCLOUD Technical Support for configuration.
Output directory of the recording file in third-party cloud storage. Default is the root directory.
Possible values: [1]
Default value: 1
Recording file naming rule.
Note
Currently only "1" is supported as the unique naming format. Custom naming formats are not supported yet.
Default is 1, which means the naming format is:
"The fields in the file name have the following meanings:" "- Type: File type. V represents video file, A represents audio file, VA represents audio and video file." "- UTC: UTC time when the file started recording, time zone is UTC+0, composed of year, month, day, hour, minute, second, and millisecond."
Possible values: >= 5 and <= 3600
Default value: 10
Snapshot interval, in seconds. Valid when the recording file format is "jpg", value range is [5, 3600], default is 10.
URL of the custom callback address. If this parameter is not filled in, the callback address configured when the service was activated will be used. URL supports HTTP and HTTPS protocols.
Possible values: >= 2 and <= 60
Default value: 15
"Fragment duration, in seconds, value range is [2, 60], default is 15."
"Note: This parameter only takes effect when OutputFileFormat is "hls"."
Whether to upload fragments in real time during recording.
"Note: This parameter only takes effect when OutputFileFormat is "hls"."
Whether the M3U8 file only saves the file name of the video fragment file (such as .ts file) instead of the path of the video fragment.
"Note: Only takes effect when RealtimeUploadFragment is "true"."
StorageParams objectrequired
Note
For how to fill in each property parameter, please refer to How to fill in the cloud storage related parameters in StorageParams?
Possible values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Recording file storage service provider. Currently supported storage service providers are as follows:
Note
Region information specified by cloud storage.
Cloud storage bucket.
Access key of cloud storage. It is recommended to provide an access key with write-only permission.
Secret key of cloud storage.
AlibabaCloudVodParams object
Region information specified by Alibaba Cloud VOD.
Access key of Alibaba Cloud VOD.
Secret key of Alibaba Cloud VOD. It is recommended to provide an access key with write-only permission.
Alibaba Cloud VOD video name.
Fixed parameter provided by Alibaba Cloud VOD.
TencentCloudVodParams object
Access key of Tencent Cloud VOD.
Secret key of Tencent Cloud VOD. It is recommended to provide an access key with write-only permission.
Region information specified by Tencent Cloud VOD.
Sub-application ID of Tencent Cloud VOD.
When Vendor is 10, fill in the address of the storage service using the S3 protocol.
Responsesâ
- 200
- application/json
- Schema
- Example (from schema)
Schema
Error code.
Error description.
Request ID.
Data object
"Task ID assigned by the cloud recording service, a fixed-length string of 16 bytes. The task ID is a unique identifier for a recording lifecycle process and loses its meaning when recording ends."
{
"Code": 0,
"Message": "succeed",
"RequestId": "abcd123",
"Data": {
"TaskId": "XXXXXXXXXXXX"
}
}{
"Code": 0,
"Message": "succeed",
"RequestId": "abcd123",
"Data": {
"TaskId": "XXXXXXXXXXXX"
}
}