Merge Live Recording Files and Callback MP4 Download URL
Legacy API endpoint: Merge Live Recording Files and Callback MP4 Download URL (Legacy)
API Description
1、合并直播录制mp4文件,接口合并过程为异步处理过程
2、接口支持https协议
API URL
http://api.polyv.net/live/v3/channel/record/merge-mp4-start
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are rate-limited. See details
The interval between the start and end times of the recording files to be merged must be within 8 hours.
Recordings from three-screen layouts will be automatically reprocessed for courseware before merging into MP4.
The returned file URL (fileUrl) for a completed merge is valid for 30 days.
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 never be used directly on the client side. 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 |
| startTime | true | String | Minimum live broadcast start time of the recording files. The difference with endTime must not exceed 8 hours. 13-digit millisecond timestamp |
| endTime | true | String | Maximum live broadcast start time of the recording files. The difference with startTime must not exceed 8 hours. 13-digit millisecond timestamp |
| callbackUrl | false | String | URL for callback on merge success or failure See: Callback Description |
| fileName | false | String | File name for the merged video. Length must not exceed 64 characters |
Example
http://api.polyv.net/live/v3/channel/record/merge-mp4-start
Form Parameters:
fileName=3-25%E6%B5%8B%E8%AF%95%E5%90%88%E5%B9%B6%E5%AF%BC%E5%87%BA%E5%90%8E%E6%96%87%E4%BB%B6%E5%90%8DMP4-1&appId=frlr1zazn3&sign=EE9979208A4B8FDBBFBBFFE381859C7F&startTime=1615452767000&endTime=1615461011000&channelId=2191541×tamp=1621842028633
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 | Empty on failure. Contains relevant information on success See: data Field Description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| fileId | String | File ID |
| fileUrl | String | Returns an empty string during merging. Returns the MP4 file URL upon successful merge |
Callback Description
Real-time callback for merge results, notifying the user server of the merge task outcome.
Principle
Sends a GET request to the user server via the HTTP interface (configured callbackUrl) to push the merge result.
Example
Example as follows: http://abc.com/test.do?status=success×tamp=1603506240000&channelId=xxxx&fileIds=xxx,xxx&fileUrl=xxdxxxxx&fileName=urlxxxx
| Parameter | Type | Description |
|---|---|---|
| status | String | Processing result. success for success, error for failure |
| channelId | String | Channel ID |
| timestamp | Long | 13-digit millisecond timestamp |
| fileId | String | Merged file ID |
| fileIds | String | IDs of all files before merging |
| fileUrl | String | URL of the merged MP4 |
| fileName | String | Name of the merged file |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the 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 pooling.
private static final Logger log = LoggerFactory.getLogger(ChannelPlayBackTest.class);
/**
* 异步合并录制文件并回调MP4
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testRecordMergeMp4() 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-mp4";
String channelId = "2191541";
String startTime = "1615452025000";
String endTime = "1615453127000";
String callbackUrl = "http://abc.com";
String fileName = "测试合并导出后文件名MP4";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("startTime", startTime);
requestMap.put("endTime", endTime);
requestMap.put("callbackUrl", callbackUrl);
requestMap.put("fileName", fileName);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.postFormBody(url, requestMap);
log.info("测试异步合并录制文件并回调MP4,返回值:{}", response);
//do somethings
}
Response Example
See Global Error Description for system-wide error details.
Success Example
- Submitted video is being merged
{
"code":200,
"status":"success",
"message":"",
"data":{
"fileUrl":"",
"fileId":"015748897d214bc0cad299c0ec43a706"
}
}
- Merged file already exists
{
"code":200,
"status":"success",
"message":"",
"data":{
"fileUrl":"https://oss-live-1.videocc.net/record/record/recordf/1b348be3231615362355920a774/recordmerge-20210315161450-3ca1a3.mp4",
"fileId":"015748897d214bc0cad299c0ec43a706"
}
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
