Merge Media Files
https://rtc-api.zego.im/
When performing CDN recording, recorded media files are stored on CDN servers. You can call this API to crop and merge multiple media files.
Currently, only media files in MP3/MP4/M3U8 formats can be merged.
- Before using this API for the first time, confirm that CDN recording has been enabled. If it has not been enabled, go to the ZEGOCLOUD Console to enable it. For details, see Console - Service Configuration - CDN, or contact ZEGOCLOUD Technical Support.
- Contact ZEGOCLOUD Technical Support to enable the media file merging feature and configure a callback URL. After media file merging is completed, the Media File Merge Complete Callback will be triggered.
- Recording files merged using this feature are permanently retained, and the retention period cannot be changed through configuration. To delete a file, call the Delete Media File API.
Request
Query Parameters
- Tencent: Tencent Cloud.
- Huawei: Huawei Cloud.
-
Tencent Cloud: MP3, MP4, M3U8.
WarningWhen the CDN vendor is Tencent Cloud and the merged file is in MP3 or MP4 format, ensure that the audio format of the source file is AAC-LC. Otherwise, the merged video file may have no sound. -
Huawei Cloud: MP4, M3U8.
- 0: Default value. Merge files directly without cropping.
- 1: Crop or otherwise process media files before merging them. In this case,
InputFileId[]is invalid andHandleMediaArgs.N.FileIdmust be passed. - When Type is 0, this parameter is valid and required.
- When Type is 1, this parameter is invalid.
- Tencent Cloud: Pass the
FileIDreturned by the Recording File Generation Callback. A maximum of 10 files can be merged. - Huawei Cloud: Pass the
ObsObjectreturned by the Recording File Generation Callback. A maximum of 20 files can be merged. - Tencent Cloud: Pass the
FileIDreturned by the Recording File Generation Callback. - Huawei Cloud: Pass the
ObsObjectreturned by the Recording File Generation Callback. - When Vendor is Tencent, this parameter is required.
- When Vendor is Huawei, this parameter is optional. If it is not specified, the system automatically generates a name.
- 0 (default): The file is permanently retained and does not expire.
- Greater than 0: The file is deleted after the specified period.
- This field is valid only when Vendor is Tencent.
- If the media file merging task takes longer to complete than the specified retention period, the file will not be generated, and accessing the merged file URL provided by the Media File Merge Complete Callback will return 404.
Possible values: [MergeMedia]
API prototype parameter
https://rtc-api.zego.im/?Action=MergeMedia
💡Public parameter. Application ID, assigned by ZEGOCLOUD. Get it from the ZEGOCLOUD Admin Console.
💡Common parameter. A 16-character hexadecimal random string (hex-encoded 8-byte random number). For the generation algorithm, refer to the signature example.
💡Common parameter. Current Unix timestamp in seconds. For the generation algorithm, refer to the signature example. A maximum deviation of 10 minutes is allowed.
💡Common parameter. Signature used to verify the legitimacy of the request. Please refer to the signature mechanism to generate it.
Possible values: [2.0]
Default value: 2.0
💡Public parameter. Signature version number.
Possible values: [Tencent, Huawei]
Possible values and corresponding CDN vendors:
Default value: MP4
Format of the merged file. The default format is MP4.
Possible values: [0, 1]
Default value: 0
Merge operation type.
When this parameter is set to 1, it is valid only when Vendor is Tencent and is invalid when Vendor is Huawei.
Possible values: >= 1, <= 20
List of file IDs to merge. Files are merged in list order. Specifically:
Example: InputFileId[]=5285890813221514958&InputFileId[]=5285890813221513290
Possible values: >= 1, <= 10
This parameter is valid when Type is 1.
List of file IDs to crop and then merge. Files are merged in ascending order of N in the parameter names. A maximum of 10 files can be merged.
For example, HandleMediaArgs.0.FileId=5285890813221514958&HandleMediaArgs.1.FileId=5285890813221513290
HandleMediaArgs.N.FileIdDefault value: 0
Start-time offset for cropping the media file corresponding to HandleMediaArgs.N.FileId. The default value is 0, in seconds.
For example, HandleMediaArgs.0.StartTime specifies the start time for cropping the media file identified by HandleMediaArgs.0.FileId.
HandleMediaArgs.N.StartTimeEnd-time offset for cropping the media file corresponding to HandleMediaArgs.N.FileId. The default value is the end time of the video file, in seconds.
For example, HandleMediaArgs.0.EndTime specifies the end time for cropping the media file identified by HandleMediaArgs.0.FileId.
HandleMediaArgs.N.EndTimeHandleMediaArgs.0.FileId=5576678019238910395&
HandleMediaArgs.0.StartTime=0.5&
HandleMediaArgs.0.EndTime=10.5&
HandleMediaArgs.1.FileId=5576678019238910395&
HandleMediaArgs.1.StartTime=10&
HandleMediaArgs.1.EndTime=15Name of the merged media file, excluding the file format.
URL-encode the value of this parameter before passing it.
Default value: 0
Valid retention period of the merged media file, in hours. File expiration time = API request time + valid retention period.
Responses
- 200
- application/json
