Video understanding and clipping - Public API

更新时间:
复制 MD 格式

Version history

Version

Description

Time

v1.1

  1. Submit video clipping tasks

  2. Batch query video clipping tasks

2025-03-13

Authentication

Prerequisites

  1. Obtain an Alibaba Cloud account, and then use a RAM user to generate an AccessKey pair.

  2. The Alibaba Cloud account must grant RAM authorization to a RAM user to generate an AK/SK.

  3. Log on to the platform with your Alibaba Cloud account and sign the relevant legal agreements.

API details

1. Submit a video clipping task

API: CreateVideoClipTask

1.1. Request parameters

Parameter

Type

Required

Description

Example

ossKeys

Array

Yes

The OSS addresses of the videos. You can specify up to 10 videos. The total size cannot exceed 500 MB, and the total duration cannot exceed two hours. Only the MP4 format is supported.

["api/test.mp4", "api/test1.mp4"]

requirement

String

Yes

The requirements for clipping. The value can be up to 200 characters long.

Clip the segments where the character XX appears in the video.

description

String

No

A description of the video content.

This is a video with an XXX background.

1.2. Response parameters

Parameter

Type

Description

Example

taskId

String

The task ID.

11

2. Batch query video clipping task information

API: BatchGetVideoClipTask

2.1. Request parameters

Parameter

Type

Required

Description

Example

taskIdList

Array

Yes

A collection of task IDs.

["11","22"]

2.2. Response parameters

Parameter

Type

Description

Example

taskList

Array

The details of the video clipping tasks.

[{},{}]

Task

Parameter name

Type

Description

Example

taskId

String

The task ID.

11111

status

String

FINISHED - The task is complete.

PENDING - The task is waiting to be processed.

NOT_EXIST - The task does not exist.

FINISHED

totalToken

Long

The total number of tokens.

4333

totalDuration

Double

The total duration in milliseconds.

213000

videoList

Array

The details of the video clips.

[{},{}]

Video

Parameter Name

Type

Description

Example

title

String

The subject of the clip.

New car launch

description

String

A description of the clip content.

New car launch promotion

videoUrl

String

The URL to view the video.

http://111.com

videoDownloadUrl

String

The URL to download the video.

http://111.com

videoName

String

The name of the original video file.

Test video

beginTime

Integer

The start time of the clip relative to the original video, in milliseconds.

0

endTime

Integer

The end time of the clip relative to the original video, in milliseconds.

12000

errorMsg

String

The reason why the video clipping task failed.

Task timeout

3. Get an OSS upload signature

API: GetOssUploadToken

3.1. Request parameters

Parameter

Type

Required

Description

Example

fileName

String

Yes

The name of the file to upload. File names must be unique.

Test video

fileType

String

Yes

The scenario where the uploaded file is used: VideoClip - Video clipping.

VideoClip

uploadType

String

Yes

The upload method: 1 - Upload using a signed URL.

1

3.2. Response parameters

Parameter

Type

Description

Example

url

String

The URL for file upload.

http://oss.xxxxx

key

String

The OSS key.

api/test.mp4

SDK download and update

PHP

Reference

require 'vendor/autoload.php';
use AlibabaCloud\SDK\Imarketing\V20220704\Models\GetOssUploadSignatureRequest;
use AlibabaCloud\SDK\IntelligentCreation\V20240313\IntelligentCreation;
use Darabonba\OpenApi\Models\Config as AlibabaConfig;

$config = new AlibabaConfig();
$config->accessKeyId = '****';
$config->accessKeySecret = '****';
$config->endpoint = "intelligentcreation.cn-zhangjiakou.aliyuncs.com";

$intelligentCreationClient = new IntelligentCreation($config);

// Example for the GetOssUploadToken API
$request = new GetOssUploadSignatureRequest();
$request->fileName = 'xxx.png';
$request->fileType = "ProductImage";
try {
    $response = $intelligentCreationClient->getOssUploadToken($request);
    var_dump($response->toMap());
} catch (TeaError $e) {
    Log::error($e);
}

2.12.0

composer require alibabacloud/intelligentcreation-20240313 2.12.0

Java

Reference

package com.aliyun.intelligentcreation20240313;

import com.aliyun.intelligentcreation20240313.models.*;
import com.aliyun.tea.TeaException;
import com.aliyun.teaopenapi.models.Config;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class TestVideoClip {

    String url = "intelligentcreation.cn-zhangjiakou.aliyuncs.com";
    String ak = ""; 
    String sk = "";
    Config config = new Config().setAccessKeyId(ak)
            .setAccessKeySecret(sk)
            .setEndpoint(url);
    // Create a client.
    Client client = new Client(config);

    public TestVideoClip() throws Exception {
    }


    public static void main(String[] args) throws Exception {
        TestVideoClip testVideoClip = new TestVideoClip();
       testVideoClip.getOssToken();
       testVideoClip.CreateVideoClipTask();
        testVideoClip.batchGetVideoClipTask();
    }


    public void CreateVideoClipTask() throws Exception {
        Gson gson = new Gson();

        CreateVideoClipTaskRequest request = CreateVideoClipTaskRequest.build(new HashMap<>());
        List<String> ossKeys = new ArrayList<>();
        ossKeys.add("video_slicing_tmp/openApi/1539704706413278/1740722903556-test01.mp4");
        request.setOssKeys(ossKeys);
        request.setRequirement("Each clip needs to output a subject, highlight analysis, and detailed interpretation.");
        request.setDescription("This is a video of an online English class where Teacher Xiaoyu is teaching English words.");
        try {
            // Call the API.
            CreateVideoClipTaskResponse response = client.createVideoClipTask(request);
            System.out.println(gson.toJson(response));

            if (response.getStatusCode().equals(200)) {
                System.out.println("The CreateVideoClipTask request was successful.");
            }
        } catch (TeaException e) {
            System.out.println(gson.toJson(e));
        }
    }

    public void batchGetVideoClipTask() throws Exception {
        Gson gson = new Gson();

        BatchGetVideoClipTaskRequest request = BatchGetVideoClipTaskRequest.build(new HashMap<>());
        List<String> ossKeys = new ArrayList<>();
        ossKeys.add("868940315698937856");
        ossKeys.add("868939847545192448");
        ossKeys.add("868135095230611456");
        ossKeys.add("868946929948655616");
        ossKeys.add("869300521721544704");
        ossKeys.add("11");
        request.setTaskIdList(ossKeys);

        try {
            BatchGetVideoClipTaskResponse response = client.batchGetVideoClipTask(request);
            System.out.println(gson.toJson(response));

            if (response.getStatusCode().equals(200)) {
                System.out.println("The batchGetVideoClipTask request was successful.");
            }
        } catch (TeaException e) {
            System.out.println(gson.toJson(e));
        }
    }


    public void getOssToken() throws Exception {
        Gson gson = new Gson();
        GetOssUploadTokenRequest request = new GetOssUploadTokenRequest();
        request.setFileName("test01.mp4");
        request.setFileType("VideoClip");
        request.setUploadType(1);

        GetOssUploadTokenResponse response = client.getOssUploadToken(request);
        System.out.println(gson.toJson(response));
        if (response.getStatusCode().equals(200)) {
            System.out.println("The getOssToken request was successful.");
        }
    }


}

2.12.0

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>intelligentcreation20240313</artifactId>
  <version>2.12.0</version>
</dependency>