tencent cloud

文档反馈

多任务接口

最后更新时间:2024-03-13 10:25:33

    简介

    本文档提供关于提交多任务的 API 概览和 SDK 示例代码。
    API
    操作描述
    提交多任务
    用于提交多个任务。

    提交多任务

    功能说明

    用于提交多个任务。

    方法原型

    public Guzzle\\Service\\Resource\\Model createMediaJobs(array $args = array());

    请求示例

    <?php
    
    require dirname(__FILE__) . '/../vendor/autoload.php';
    
    $secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.tencentcloud.com/cam/capi
    $secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.tencentcloud.com/cam/capi
    $region = "ap-beijing"; //替换为用户的 region,已创建桶归属的region可以在控制台查看,https://console.tencentcloud.com/cos5/bucket
    $cosClient = new Qcloud\\Cos\\Client(
    array(
    'region' => $region,
    'schema' => 'https', //协议头部,默认为http
    'credentials'=> array(
    'secretId' => $secretId ,
    'secretKey' => $secretKey)));
    try {
    // 多任务接口 https://www.tencentcloud.com/document/product/436/58335?from_cn_redirect=1
    $result = $cosClient->CreateMediaJobs(array(
    'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucket
    'Tag' => 'Transcode', // 可选,单一任务时,优先以Operation.Tag为准,当Operation无Tag参数时,该参数生效
    'QueueId' => 'paaf4fce5521a40888a303xxxxxxxxxxxxxx',
    'CallBack' => '',
    'Input' => array(
    'Object' => 'example.mp4'
    ),
    'Operation' => array(
    array(
    'Tag' => 'Transcode',
    'TemplateId' => 't04e1ab86554984f1aa17cxxxxxxxxxxxxxx',
    'Output' => array(
    'Region' => $region,
    'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucket
    'Object' => 'video01.mp4',
    ),
    'WatermarkTemplateId' => array(
    't112d18d9b2a9b430e91dxxxxxxxxxxxxxx',
    ),
    ),
    array(
    'Tag' => 'Transcode',
    'TemplateId' => 't04e1ab86554984f1aa17xxxxxxxxxxxxxx',
    'Output' => array(
    'Region' => $region,
    'Bucket' => 'examplebucket-1250000000', //存储桶名称,由BucketName-Appid 组成,可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucket
    'Object' => 'video02.mp4',
    ),
    'WatermarkTemplateId' => array(
    't1bf713bb5c6a5496e859axxxxxxxxxxxxxx',
    ),
    ),
    ),
    ));
    print_r($result);
    } catch (\\Exception $e) {
    // 请求失败
    echo($e);
    }

    参数说明

    Request 中的具体数据描述如下:
    节点名称(关键字)
    父节点
    描述
    类型
    是否必选
    Input
    Request
    待操作的媒体信息
    Container
    Operation
    Request
    操作规则,个数不超过6个
    Container
    QueueId
    Request
    任务所在的队列 ID
    String
    Container 类型 Input 的具体数据描述如下:
    节点名称(关键字)
    父节点
    描述
    类型
    是否必选
    Object
    Request.Input
    媒体文件名
    String
    Container 类型 Operation 的具体数据描述如下:
    节点名称(关键字)
    父节点
    描述
    类型
    是否必选
    Tag
    Request.Operation
    任务类型: Animation、Transcode、SmartCover、Snapshot
    Container
    TemplateId
    Request.Operation
    指定的模板 ID
    String
    Output
    Request.Operation
    结果输出地址
    Container
    Container 类型 Output 的具体数据描述如下:
    节点名称(关键字)
    父节点
    描述
    类型
    是否必选
    Region
    Request.Operation.Output
    存储桶的地域
    String
    Bucket
    Request.Operation.Output
    存储结果的存储桶
    String
    Object
    Request.Operation.Output
    输出结果的文件名
    String

    返回结果示例

    GuzzleHttp\\Command\\Result Object
    (
    [Body] => GuzzleHttp\\Psr7\\Stream Object
    (
    [stream:GuzzleHttp\\Psr7\\Stream:private] => Resource id #88
    [size:GuzzleHttp\\Psr7\\Stream:private] =>
    [seekable:GuzzleHttp\\Psr7\\Stream:private] => 1
    [readable:GuzzleHttp\\Psr7\\Stream:private] => 1
    [writable:GuzzleHttp\\Psr7\\Stream:private] => 1
    [uri:GuzzleHttp\\Psr7\\Stream:private] => php://temp
    [customMetadata:GuzzleHttp\\Psr7\\Stream:private] => Array
    (
    )
    
    )
    
    [RequestId] => NjI2MTAJOIDSjoiajsdoSDOASDHJoimY2YTQ=
    [ContentType] => application/xml
    [ContentLength] => 1731
    [Bucket] => examplebucket-1250000000
    [Location] => examplebucket-1250000000.ci.ap-beijing.myqcloud.com/jobs
    [Response] => Array
    (
    [JobsDetail] => Array
    (
    [0] => Array
    (
    [Code] => Success
    [CreationTime] => 2022-04-21T18:03:31+0800
    [EndTime] => -
    [Input] => Array
    (
    [BucketId] => examplebucket-1250000000
    [Object] => video01.mp4
    [Region] => ap-beijing
    )
    
    [JobId] => j4c211cas9a87sd90d80a988627cb30
    [Message] =>
    [Operation] => Array
    (
    [Output] => Array
    (
    [Bucket] => examplebucket-1250000000
    [Object] => Transcode-01.flv
    [Region] => ap-beijing
    )
    
    [TemplateId] => t0b6128z8c098z09xcsd89s0a5dca38
    [TemplateName] => FLV-SD
    [WatermarkTemplateId] => t185z90x8c9z0da5sd67a5a19c
    )
    
    [Progress] => 0
    [QueueId] => pzx8c09za90sd890a8d09aa0757be086
    [StartTime] => -
    [State] => Submitted
    [Tag] => Transcode
    )
    
    [1] => Array
    (
    [Code] => Success
    [CreationTime] => 2022-04-21T18:03:31+0800
    [EndTime] => -
    [Input] => Array
    (
    [BucketId] => examplebucket-1250000000
    [Object] => video01.mp4
    [Region] => ap-beijing
    )
    
    [JobId] => j4cz9x7c8z9xcsda98sd09ad80627cb30
    [Message] =>
    [Operation] => Array
    (
    [Output] => Array
    (
    [Bucket] => examplebucket-1250000000
    [Object] => Transcode-02.flv
    [Region] => ap-beijing
    )
    
    [TemplateId] => t0bz98xc789zxs9d80a8sd90asd37f83c
    [TemplateName] => FLV-HD
    [WatermarkTemplateId] => t18zc8z90csd876a78sdas87d8a19c
    )
    
    [Progress] => 0
    [QueueId] => p81zxc908zaf2aee496a09s8d90as8d90
    [StartTime] => -
    [State] => Submitted
    [Tag] => Transcode
    )
    
    )
    
    )
    
    )
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持