Polyv Help Center

Help Center

Merge Videos

Updated: 2025-01-14 16:05:09

API Description

1、通过视频id合并视频
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

API URL

http://api.polyv.net/v2/video/{userid}/concat

Online API Call

Request Method

POST

API Constraints

  1. 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
ptime true Long Current time in milliseconds, 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 stored or used directly on the client side. All API calls must be relayed through your own server to the POLYV server for response data. See signature generation rules
vids true String Video IDs, separated by commas. Supports up to 50 videos, but the total merged video duration must not exceed 5 hours.
title false String Video title. Default is "Merge-" + the title of the first video. Titles longer than 128 characters will be truncated.
cataId false Long Category ID. If not provided, the default category is used. Obtain category IDs via the Get Categories and Subcategories API.
luping false Integer Enable screen recording optimization. Default is disabled.
1: Enable
0: Disable

Example

http://api.polyv.net/v2/video/1b448be323/concat

Form parameters:

vids=1b448be323615635294a548b3c8a9953_1%2C1b448be323d7e4c49d5634abd5af0bcb_1&sign=B57441EA62B20F95E1E2B6E3A6CFE6A27FD98741&cataId=1602671097888&luping=1&title=%E5%90%88%E5%B9%B6%E7%BE%8E%E9%A3%9F%E8%A7%86%E9%A2%91&ptime=1617845667416

Response Parameters

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 Object Returns merged video information on success. See data field description
data parameter description
Parameter Type Description
concatVid String Merged video ID

Error Code List

Error Code message Description
400 sign can not be empty. Signature is empty
400 ptime is too old. Timestamp expired
400 ptime is illegal. Timestamp format is invalid or exceeds current time by more than 3 minutes
400 Could not find user by userid. User ID does not exist
400 the sign is not right. Incorrect signature
410 vid is blank. VID is empty
411 illegal videos' count, count=5 Invalid number of videos
412 illegal vid, vid=error_vid Video does not belong to the user
413 swf video is not support, vid=error_vid SWF format is not supported
414 illegal vid. vid=error_vid Video does not exist or the highest bitrate has not been transcoded
415 category no exists, cataid=error_cataid Category not found
416 keepsource category is not support, cataid=error_cataid Category does not support source file playback
417 concat video failed. backed error=xx Backend processing failed
500 failed. Backend error

Java Request Example

For quick integration, please download the relevant dependency source code. Click to download source code. Add it to your project after downloading. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.

It is strongly recommended to use the VOD Java SDK for API integration. The VOD 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(VodClipTest.class);
/**
 * 合并视频
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testCombineVideo() throws Exception, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String secretKey = super.secretKey;
    String userId = super.userId;
    String ptime = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/v2/video/"+userId+"/concat";
    String vids = "1b448be323615635294a548b3c8a9953_1,1b448be323d7e4c49d5634abd5af0bcb_1";
    String title="合并美食视频";
    String cataId = String.valueOf("1602671097888"); 
    String luping = String.valueOf(1);

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("ptime", ptime);
    requestMap.put("vids", vids);
    requestMap.put("title", title);
    requestMap.put("cataId", cataId);
    requestMap.put("luping", luping);
    requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
    String response = HttpUtil.postFormBody(url,requestMap);
    log.debug("测试合并视频,{}", response);
    //do somethings

}

Response Example

For global system error descriptions, see Global Error Description

Success Example

{
    "code":200,
    "status":"success",
    "message":"success",
    "data":{
        "concatVid":"1b448be323b452641878b54f21241188_1"
    }
}

Error Example

{
  "code": 400,
  "status": "error",
  "message": "ptime is too old.",
  "data": ""
}
联系客服,在线咨询