Merge Live Recordings
API Description
1、合并直播录制文件,保存至频道号内视频库,接口合并过程为异步处理过程
2、接口支持https协议
API URL
http://api.polyv.net/live/v3/channel/record/merge
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
The number of MP4 files to merge cannot exceed 15, and the total duration of the merged video cannot exceed 24 hours.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId [See Get Secret Key] |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client. All APIs must be called through your own server to relay requests to the POLYV server for response data. [See Signature Generation Rules] |
| channelId | true | String | Channel ID |
| fileIds | true | String | Recording video file IDs to merge. Separate multiple IDs with commas. [fileId can be obtained via Query Channel Recording Video Info] |
| fileName | false | String | File name for the merged video |
| callbackUrl | false | String | Callback URL for merge success or failure. Custom parameters can be appended. [See Callback Description] |
| autoConvert | false | String | Whether to automatically save to VOD. Default is N. Y: Automatically save to the corresponding VOD category (VOD save path: Live Replay - Channel ID - Session) N: Do not automatically save |
| mergeMp4 | false | String | File type after merging. Default is N. Y: Merge into MP4 file N: Merge into m3u8 file |
| orderByCustom | false | String | Whether to merge in the order of the fileIds parameter. Values: Y or N. Default is N, which merges in the order of broadcast start time. |
Example
http://api.polyv.net/live/v3/channel/record/merge
Form Parameters:
mergeMp4=N&fileName=%E6%B5%8B%E8%AF%95%E5%BC%82%E6%AD%A5%E5%90%88%E5%B9%B633333&fileIds=46a586558b9e716c2cc2802a52b9e907%2C9a41298b5f032f3d5a8119b104c5dfcc&appId=frlr1zazn3&sign=1C08E1AB4882DEFB00CC2A5582472A03&autoConvert=N&callbackUrl=http%3A%2F%2Fabc.com&channelId=2191541×tamp=1621841986670
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. [See Global Error Description] |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides additional error details. |
| data | String | On success, returns submission success info. "processing.": Merge task is being processed. "submit success.": Merge task submitted successfully. |
Callback Description
Real-time callback for merge results, notifying users of the merge task outcome.
Principle
Sends a GET request to the user's server via the HTTP interface (set callbackUrl) to push the merge result.
Example
Example: http://abc.com/test.do?status=success×tamp=1603506240000&fileId=xxxx&fileIds=xxx,xxx&sign=xxdxxxxx&fileUrl=urlxxxx&fileName=xxxx
| Parameter | Type | Description |
|---|---|---|
| status | String | API processing result. success or error |
| timestamp | Long | Current 13-digit millisecond timestamp |
| fileId | String | Merged file ID, returned on success |
| fileIds | String | File IDs before merging |
| fileUrl | String | URL of the merged video file, returned on success |
| fileName | String | Name of the merged file, returned on success |
| sign | String | Encrypted string for verification. Generated using md5(AppSecret+timestamp). AppSecret is the key used by the live streaming system. |
Java Request Example
For quick integration, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(ChannelPlayBackTest.class);
/**
* 异步合并直播录制文件
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testRecordFileMergeAsync() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v3/channel/record/merge";
String channelId = "2191541";
String fileIds = "249fd64bdf9329aa1e1c1228fb0732cd,66fda01de2e11bf1d91e801ea7cbc431";
String fileName = "合并后文件名MP4";
String callbackUrl = "http://abc.com";
String autoConvert = "N";
String mergeMp4 = "Y";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("fileIds", fileIds);
requestMap.put("fileName", fileName);
requestMap.put("callbackUrl", callbackUrl);
requestMap.put("autoConvert", autoConvert);
requestMap.put("mergeMp4", mergeMp4);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.postFormBody(url, requestMap);
log.info("测试异步合并直播录制文件,返回值:{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"",
"data":"submit success."
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
