Transcoding jobs

Updated at:

Initiate and query transcoding jobs in Intelligent Media Services by calling API operations with a server-side SDK.

Usage notes

To initiate a transcoding job, submit the job with the regionId, Inputs, and OutputGroups parameters. After the job is processed, you can use the returned JobId to query the job information.

Note the following about transcoding job parameters:

  • regionId is the region where the service is provided.

  • Inputs and OutputGroups files corresponding to OutputGroups must be in the same region regionId.

  • Obtain templateId from the transcoding template management page.

For complete parameter structure see MediaConvertJobConfig.

Note

For a list of supported regionId, please refer Service regions.

Sample code

To debug online, use the Alibaba Cloud OpenAPI Developer Portal.

<?php

namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\ICE\V20201109\ICE;
use AlibabaCloud\Credentials\Credential;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\ICE\V20201109\Models\SubmitMediaConvertJobRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    public static function createClient(){
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        $config->endpoint = "ice.cn-shanghai.aliyuncs.com";
        return new ICE($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $submitMediaConvertJobRequest = new SubmitMediaConvertJobRequest([
            "config" => "{\"Inputs\":[{\"InputFile\":{\"Type\":\"OSS\",\"Media\":\"http://<bucket name>.oss-cn-shanghai.aliyuncs.com/input/**/60min.mp4\"}}],\"OutputGroups\":[{\"GroupConfig\":{\"Type\":\"File\",\"OutputFileBase\":{\"Type\":\"OSS\",\"Media\":\"http://<bucket name>.oss-cn-shanghai.aliyuncs.com/output/**/\"}},\"Outputs\":[{\"OutputFileName\":\"hd.mp4\",\"TemplateId\":\"<TemplateId>\"},{\"OutputFileName\":\"sd.mp4\",\"TemplateId\":\"<TemplateId>\"}]}]}",
            "userData" => "{\"videoId\":\"abcd\"}"
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->submitMediaConvertJobWithOptions($submitMediaConvertJobRequest, $runtime);
        }
        catch (Exception $error) {
            if (!($error instanceof TeaError)) {
                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            var_dump($error->message);
            var_dump($error->data["Recommend"]);
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));

Related API operations