Trim Recording File
API Description
1、裁剪直播录制视频文件,裁剪文件过程为异步处理过程
2、裁剪视频的最小粒度仅支持到单位为秒(s)的裁剪
3、接口支持https协议
API URL
http://api.polyv.net/live/v3/channel/record/clip
Request Method
POST
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Request Parameters
| 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 |
| fileId | true | String | File ID Can be obtained via Query Channel Recording Video Info |
| deleteTimeFrame | true | String | Time intervals to trim and remove Input format requirements: (1) start and end values are in seconds, format: [{"start":xx, "end":xx},{"start":xx, "end":xx}](2) Multiple intervals must be sorted in ascending order by time (3) Time intervals must not overlap (4) Maximum of 100 intervals [Example: To trim and remove intervals from 1s to 14s and 25s to 30s, input string: [{"start":1, "end":14},{"start":25, "end":30}] ]Accuracy notes: (1) Trimming intervals have a certain time error (2) Reason: Playback defaults to m3u8 format trimming. Since m3u8 video trimming is precise to each TS segment, the system determines which TS segments are covered by the removal intervals. For more precise trimming, contact POLYV customer service to enable MP4 trimming |
| callbackUrl | false | String | Callback URL for trim success or failure See Callback Description |
| autoConvert | false | String | Whether to automatically save the playback to on-demand, default is N Y: Yes N: No |
| fileName | false | String | File name after trimming |
Example
http://api.polyv.net/live/v3/channel/record/clip
Form parameters:
fileName=3-25%E6%B5%8B%E8%AF%95%E8%A3%81%E5%89%AAN%E4%B8%8D%E8%BD%AC%E5%AD%98&appId=frlr1zazn3&deleteTimeFrame=%5B%7B%22start%22%3A1%2C%22end%22%3A30%7D%2C%7B%22start%22%3A50%2C%22end%22%3A60%7D%5D&sign=BCA5136EEE29D14C0EA483BD5FC24464&autoConvert=N&callbackUrl=http%3A%2F%2Fxxxx&channelId=2191541×tamp=1621841922358&fileId=249fd64bdf9329aa1e1c1228fb0732cd
Response Parameters
| 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 | On success, returns submission confirmation "submit success.": The submitted video is being trimmed |
Callback Description
Real-time callback for trimming results, notifying users of the task outcome.
Principle
Sends a GET request to the user's server via HTTP (using the configured callbackUrl) to push the merge result.
Example
Example: http://abc.com/test.do?status=success&fileId=xxxx&channelId=xxx&sign=xxdxxxxx&clippedFileId=xxx&fileName=xxxx×tamp=xxx&actualTimeFrame=xxx
| Parameter | Type | Description |
|---|---|---|
| status | String | Processing result, success or error |
| channelId | String | Channel ID, returned on success |
| fileId | String | File ID after trimming, returned on success |
| clippedFileId | String | File ID before trimming, returned on success |
| fileUrl | String | Video URL after trimming, returned on success |
| timestamp | String | Current callback timestamp |
| sign | String | Encrypted string for verification, generated as md5(AppSecret+timestamp), AppSecret is the live system secret key |
| actualTimeFrame | String | Actual retained time intervals after trimming, URL-encoded string, format: [{"start":xx, "end":xx},{"start":xx, "end":xx}] |
| fileName | String | File name, URL-encoded string |
Java Request Example
For quick integration, download the relevant dependency source code. Click to download source code. After downloading, add it to your project. The test cases include HttpUtil.java and LiveSignUtil.java in the download package.
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);
/**
* 异步裁剪直播录制文件
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testClipRecordFile() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "https://api.polyv.net/live/v3/channel/record/clip";
String channelId = "2191532";
String fileId = "635b8e3c74d8a43530a138b0e75d841e";
String deleteTimeFrame = "[{\"start\":1, \"end\":30},{\"start\":50, \"end\":60}]";
String callbackUrl="http://xxxx";
String autoConvert="N";
String fileName="fileName";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("fileId", fileId);
requestMap.put("deleteTimeFrame", deleteTimeFrame);
requestMap.put("callbackUrl", callbackUrl);
requestMap.put("autoConvert", autoConvert);
requestMap.put("fileName", fileName);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.postFormBody(url, requestMap);
log.info("测试异步裁剪直播录制文件,返回值:{}", response);
//do somethings
}
Response Example
See Global Error Description for system-wide error explanations.
Success example
{
"code":200,
"status":"success",
"message":"",
"data":"submit success."
}
Error example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
