Polyv Help Center

Help Center

Batch Transfer Temporary Videos to Cloud Video on Demand

Updated: 2023-10-13 10:34:04

Interface Description

1、批量转存直播暂存录制视频文件到点播列表,接口转存过程为异步处理过程
2、接口支持https协议

Interface URL

http://api.polyv.net/live/v3/channel/record/convert

Online API Call

Request Method

POST

Interface Constraints

  1. The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details on obtaining keys
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 not be saved or used directly on the client side. All APIs must be relayed through the customer's own server to call the POLYV server for response data. See details on signature generation rules
channelId true String Channel ID
fileIds true String Recording video file IDs to transfer. Multiple IDs separated by commas. fileId can be obtained via Query Channel Recording Video Information
fileName false String File name after transfer. Currently, multiple file names are not supported.
canRepeat false Integer Whether to return success if the video exists in the VOD recycle bin. Default value is 1 (Note: When the parameter is 1, the interface returns success but will not actually re-transfer the VOD video). It is recommended to pass 0
1: Return success
0: Return error
cataId false String Directory ID in VOD for the transfer. Default is the root directory ID in VOD.
callbackUrl false String Callback notification URL upon successful transfer See details on callback description

Example

http://api.polyv.net/live/v3/channel/record/convert

Form Parameters:

fileName=%E6%B5%8B%E8%AF%95%E5%BC%82%E6%AD%A5%E8%BD%AC%E5%AD%98&fileIds=9a41298b5f032f3d5a8119b104c5dfcc%2C66fda01de2e11bf1d91e801ea7cbc431&appId=frlr1zazn3&sign=48F5D4ADC2A81256D906CCE715A2C267&cataId=1410431629027&callbackUrl=http%3A%2F%2Fabc.com&channelId=2191541&timestamp=1621840957439

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 indicates success, non-200 indicates failure See details on global error description
status String Response status text information
message String Response description message. When code is 400 or 500, it provides auxiliary error description.
data String Returns submission success information upon successful request.
"submit success.": Transfer task submitted successfully
"processing.": Transfer task is being processed

Callback Description

Real-time callback of transfer results, allowing timely notification of the transfer task outcome to the user.

Principle

Sends a GET request to the user's server via the HTTP interface (set callbackUrl) to push the transfer result.

Example

Example as follows: http://abc.com/test.do?channelId=123456&vid=e6b23c6f5134943a015bc117e2854eae_e&title=视频标题&duration=01:23:45&fileSize=123400&timestamp=1557976774000&sign=xxxxxxxxxx&fileId=359a81ed8fd8cb83d88ddcd97d9e8a2b&videoId=b1c6f3ad2c&origin=auto&sessionIds=["20190703145126,4,fdqbopvtnv","20190703145126,8,fdqbopvtnv"]

Transfer Success Callback Parameters
Parameter Type Description
status String Interface processing result. success for success, error for failure
channelId String Channel ID
vid String Video ID of the successfully transferred video
title String Video title
duration String Video duration, format: HH:mm:ss
fileSize Long Video file size (unit: bytes)
timestamp Long 13-digit millisecond timestamp
sign String Encrypted string for verification. Generation rule: md5(AppSecret+timestamp). AppSecret is the key for the live streaming system.
sessionIds String Array string corresponding to recording sessions and times. Format: ["20190703145126,4,fdqbopvtnv","20190703145126,8,fdqbopvtnv"], where "20190703145126,4,fdqbopvtnv": first field is start time, second is live duration, third is the corresponding sessionId.
fileId String Corresponding recording file ID for the transfer
videoId String Unique ID for the transferred replay
origin String Recording source for the transfer
manual: Cloud recording
auto: Auto recording
merge: Merge
clip: Clip
sessionId String Corresponding single session ID for the replay
userId String POLYV user ID, consistent with the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings)
Transfer Failure Callback Parameters
Parameter Type Description
status String Interface processing result. success for success, error for failure
code String Error code
userExpired: User expired
spaceOverSize: Insufficient VOD space
unknown: Unknown error
userId String POLYV user ID, consistent with the Polyv official website. Path: Official website -> Login -> Live Streaming (Development Settings)
channelId String Channel ID
fileId String Transferred file ID
sign String Encrypted string for verification. Generation rule: md5(AppSecret+timestamp). AppSecret is the key for the live streaming system.
timestamp Long Current 13-digit millisecond timestamp

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 code 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 functionality integration. The Live Java SDK provides unified packaging and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.

private static final Logger log = LoggerFactory.getLogger(ChannelPlayBackTest.class);
/**
 * 异步批量转存录制文件到点播
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void testRecordConvert() 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/convert";
    String channelId = "2139283";
    String fileIds = "97e6b0ca2422069be036507218b7c2fb";
    String fileName = "测试异步转存";
    String cataId = "1410431629027";
    String callbackUrl = "http://abc.com";
    
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("channelId", channelId);
    requestMap.put("fileIds", fileIds);
    requestMap.put("fileName", fileName);
    requestMap.put("cataId", cataId);
    requestMap.put("callbackUrl", callbackUrl);
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.postFormBody(url, requestMap);
    log.info("测试异步批量转存录制文件到点播,返回值:{}", response);
    //do somethings
    
}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "code":200,
    "status":"success",
    "message":"",
    "data":"submit success."
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询