Merge Live Recording Files and Callback MP4 Download URL
New API endpoint: Merge Live Recording Files and Callback MP4 Download URL
In the old API, startTime and endTime were filtered based on creation time, but neither the live streaming backend nor the query API returned the creation time, making it difficult to use. It is recommended to use the new API.
API Description
1、合并直播录制mp4文件,接口合并过程为异步处理过程
2、接口支持https协议
API URL
http://api.polyv.net/live/v3/channel/record/merge-mp4
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 interval between the start and end of the merged recording files must be within 8 hours.
Recordings with three-screen content will be automatically reprocessed for courseware before merging into MP4.
The returned file URL (fileUrl) 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 and must never be saved or used directly on the client side. All APIs must be called through the customer's 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 recording file creation time, must not exceed 8 hours from endTime, in 13-digit millisecond timestamp |
| endTime | true | String | Maximum recording file creation time, must not exceed 8 hours from startTime, in 13-digit millisecond timestamp |
| callbackUrl | false | String | Callback URL for merge success or failure See Callback Description |
| fileName | false | String | File name of the merged video, length must not exceed 64 characters |
Example
http://api.polyv.net/live/v3/channel/record/merge-mp4
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 for success, non-200 for failure See Global Error Description |
| status | String | Response status text |
| message | String | Response description, provides error details when code is 400 or 500 |
| data | String | Empty on failure, relevant information on success See data Field Description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| fileId | String | File ID |
| fileUrl | String | Returns empty string during merging, returns MP4 file URL after successful merge |
Callback Description
Real-time callback of merge results to notify 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 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 | All file IDs before merging |
| fileUrl | String | Merged MP4 URL |
| fileName | String | Merged file name |
Java Request Example
For quick integration of basic code, 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);
/**
* 异步合并录制文件并回调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 descriptions.
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": ""
}
