Set Keyframe Information
API Description
1、通过视频id设置单个视频的打点信息
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口仅userid、ptime、vid参与签名,其他参数不参与签名
4、接口支持https协议
API URL
http://api.polyv.net/v2/video/{userid}/saveKeyFrame
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. API calls have frequency limits. Click for details
The request parameter
seconds(keyframe timestamp) must be less than the video duration.The number of request parameters
desc(keyframe descriptions) must match the number ofseconds(keyframe timestamps).
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It 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 |
| vid | true | String | Video ID |
| desc | true | String | Keyframe descriptions. For multiple keyframes, separate with commas "," |
| seconds | true | String | Keyframe timestamps. For multiple keyframes, separate with commas "," |
| btnsettingswitch | false | String | Keyframe button settings switch. Leave empty to disable. Y: Enable N: Disable |
| btndesc | false | String | Button description, required when the button switch is enabled |
| btnhref | false | String | Button redirect URL, required when the button switch is enabled |
Example
http://api.polyv.net/v2/video/1b448be323/saveKeyFrame
Form Parameters:
vid=1b448be323a6a1a6c0c237856f555e88_1&seconds=10,20&btnsettingswitch=Y&btnhref=https://baidu.com&sign=D4F867827C100835254100FF147B1095DA29BB72&btndesc=测试打点按钮&ptime=1617258980678&desc=测试打点10s,测试打点20s
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 | Returns success message upon successful request. |
Java Request Example
For quick integration of the base code, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own project source code. HttpUtil.java and VodSignUtil.java in the test cases are included in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified packaging and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
private static final Logger log = LoggerFactory.getLogger(VodChapterMakerTest.class);
/**
* 设置打点信息
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testAddChapterMarker() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/v2/video/%s/saveKeyFrame", userId);
String vid = "1b448be323a6a1a6c0c237856f555e88_1";
String desc = "测试打点10s,测试打点20s";
String seconds = "10,20";
String btnsettingswitch = "Y";
String btndesc = "测试打点按钮";
String btnhref = "https://baidu.com";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("desc", desc);
requestMap.put("seconds", seconds);
requestMap.put("btnsettingswitch", btnsettingswitch);
requestMap.put("btndesc", btndesc);
requestMap.put("btnhref", btnhref);
//系统只部分参数进行签名
Map<String, String> signMap = new HashMap<>();
signMap.put("userid", userId);
signMap.put("ptime", ptime);
signMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(signMap, secretKey));
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试设置打点信息,{}", response);
//do somethings
}
Response Example
For system-wide global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": "the key frame add successfully"
}
Error Example
{
"code": 400,
"status": "error",
"message": "the sign is not right.",
"data": ""
}
