Video quality assessment

更新时间:
复制 MD 格式

This topic provides sample code for evaluating video quality in common programming languages and for common scenarios.

Note
  • For real-time assistance, start an online consultation.

  • If you have questions about API access or usage for the Alibaba Cloud Vision AI Platform, join our DingTalk group (ID: 23109592) to contact us.

Introduction

For an introduction to the video quality assessment feature and its API parameters, see Video Quality Assessment.

Install the SDK

For information about the SDK dependencies for common languages, see SDK Overview.

Configure environment variables

Configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables.

Important
  • An Alibaba Cloud account has full access to all API operations. We recommend that you use a RAM user for API calls or routine O&M. For more information, see Create a RAM user.

  • Do not save your AccessKey ID or AccessKey Secret in project code. Otherwise, the AccessKey pair may be leaked and the security of all resources in your account may be compromised.

  • Configure environment variables on Linux and macOS

    1. Open a terminal in IntelliJ IDEA.

    2. Run the following commands to configure the environment variables.

      Replace <access_key_id> with the AccessKey ID of your RAM user and <access_key_secret> with the AccessKey Secret of your RAM user. If you need to configure more permissions, see Control access permissions using a RAM policy.

      export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id>
      export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret>
  • Configure environment variables on Windows

    Create a new environment variable file, add the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, and set them to the AccessKey ID and AccessKey Secret that you have prepared. Then, restart the Windows operating system. The following example uses Windows 10.

    1. Open File Explorer, right-click This PC, and then select Properties.

    2. In the left-side navigation pane, click Advanced system settings.

    3. On the Advanced tab of the System Properties dialog box, click Environment Variables.

    4. In the Environment Variables dialog box, click New.

    5. In the New System Variable dialog box, add the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET, and set them to the AccessKey ID and AccessKey Secret that you have prepared.

    6. Restart the Windows operating system for the configurations to take effect.

Sample code

File in an OSS bucket (Shanghai)

For sample code in common languages for querying the result of an asynchronous task, see Query the result of an asynchronous task.

// -*- coding: utf-8 -*-
// Import the required dependencies.
// The minimum required SDK version for videorecog20200320 is 1.0.7.
// You can find the latest SDK version at: https://mvnrepository.com/artifact/com.aliyun/videorecog20200320
// <dependency>
//       <groupId>com.aliyun</groupId>
//       <artifactId>videorecog20200320</artifactId>
//       <version>${aliyun.videorecog.version}</version>
// </dependency>

import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;
import com.aliyun.videorecog20200320.models.EvaluateVideoQualityResponse;

public class EvaluateVideoQuality {

    public static com.aliyun.videorecog20200320.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          Initialize the configuration object com.aliyun.teaopenapi.models.Config.
          This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
         */
         com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret);
        // The service endpoint.
        config.endpoint = "videorecog.cn-shanghai.aliyuncs.com";
        return new com.aliyun.videorecog20200320.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
        // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
        String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); 
        com.aliyun.videorecog20200320.Client client = EvaluateVideoQuality.createClient(accessKeyId, accessKeySecret);
        com.aliyun.videorecog20200320.models.EvaluateVideoQualityRequest evaluateVideoQualityRequest = new com.aliyun.videorecog20200320.models.EvaluateVideoQualityRequest()
                .setVideoUrl("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Call the API and print the response.
            EvaluateVideoQualityResponse response = client.evaluateVideoQualityWithOptions(evaluateVideoQualityRequest, runtime);
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));
        } catch (TeaException error) {
            // Get the complete error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(error));
            // Get a specific field from the error.
            System.out.println(error.getCode());
        }
    }
}
# -*- coding: utf-8 -*-
# Import the required dependencies.
# The minimum required SDK version for videorecog20200320 is 3.0.6.
# You can find the latest SDK version at: https://pypi.org/project/alibabacloud-videorecog20200320/
# pip install alibabacloud_videorecog20200320

import os
from alibabacloud_tea_openapi.models import Config
from alibabacloud_tea_util.models import RuntimeOptions
from alibabacloud_videorecog20200320.client import Client
from alibabacloud_videorecog20200320.models import EvaluateVideoQualityRequest

config = Config(
  # For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
  # If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
  # Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
  access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'),
  access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
  # The service endpoint.
  endpoint='videorecog.cn-shanghai.aliyuncs.com',
  # The ID of the region where the service is deployed.
  region_id='cn-shanghai'
)
evaluate_video_quality_request = EvaluateVideoQualityRequest(
    video_url='https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4'
)
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.evaluate_video_quality_with_options(evaluate_video_quality_request, runtime)
  # Get the complete response.
  print(response.body)
except Exception as error:
  # Get the complete error message.
  print(error)
  # Get a specific field from the error.
  print(error.code)
<?php

// Install the dependency package.
// The minimum required SDK version for videorecog-20200320 is 1.0.8.
// You can find the latest SDK version at: https://packagist.org/packages/alibabacloud/videorecog-20200320
// composer require alibabacloud/videorecog-20200320

use AlibabaCloud\SDK\Videorecog\V20200320\Videorecog;
use \Exception;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Videorecog\V20200320\Models\EvaluateVideoQualityRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class EvaluateVideoQuality {

    /**
     * Initializes the client with an AccessKey ID and an AccessKey Secret.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Videorecog Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        // Initialize the configuration object Darabonba\OpenApi\Models\Config.
        // This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
        $config = new Config([          
            "accessKeyId" => $accessKeyId,
            "accessKeySecret" => $accessKeySecret
        ]);
        // The service endpoint.
        $config->endpoint = "videorecog.cn-shanghai.aliyuncs.com";
        return new Videorecog($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
        // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.    
        $accessKeyId = getenv('ALIBABA_CLOUD_ACCESS_KEY_ID');      
        $accessKeySecret = getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
        $client = self::createClient($accessKeyId, $accessKeySecret);
        $evaluateVideoQualityRequest = new EvaluateVideoQualityRequest([
            "videoUrl" => "https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4"
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->evaluateVideoQualityWithOptions($evaluateVideoQualityRequest, $runtime);
            # Get the complete response.
            echo Utils::toJSONString($resp->body);
        } catch (Exception $exception) {
            # Get the complete error message.
            echo Utils::toJSONString($exception);
            # Get a specific field from the error.
            echo $exception->getCode();
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
// $argv is a reserved array for input parameters and should not be modified.
EvaluateVideoQuality::main(array_slice($argv, 1));
// Install the dependency package.
// npm install @alicloud/videorecog20200320
// The minimum required SDK version for videorecog20200320 is 3.0.5.
// You can find the latest SDK version at: https://npmjs.com/package/@alicloud/videorecog20200320
const VideorecogClient = require('@alicloud/videorecog20200320');
const OpenapiClient = require('@alicloud/openapi-client');
const TeaUtil = require('@alicloud/tea-util');

let config = new OpenapiClient.Config({
  // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
  // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
  // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code. 
  accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,   
  accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET
});
// The service endpoint.
config.endpoint = `videorecog.cn-shanghai.aliyuncs.com`;
const client = new VideorecogClient.default(config);
let evaluateVideoQualityRequest = new VideorecogClient.EvaluateVideoQualityRequest({
  videoUrl: "https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4",
});
let runtime = new TeaUtil.RuntimeOptions({});
client.evaluateVideoQualityWithOptions(evaluateVideoQualityRequest, runtime)
  .then(function (evaluateVideoQualityResponse) {
    // Get the complete response.
    console.log(evaluateVideoQualityResponse);
    // Get a specific field from the response.
    console.log(evaluateVideoQualityResponse.body.data);
  }, function (error) {
    // Get the complete error message.
    console.log(error);
    // Get a specific field from the error.
    console.log(error.data.Code);
  })
// -*- coding: utf-8 -*-
// Import the required dependencies.
// The minimum required SDK version for videoenhan20190930 is 2.0.7.
// You can find the latest SDK version at: https://pkg.go.dev/github.com/alibabacloud-go/videorecog-20200320/v2
// go get github.com/alibabacloud-go/videorecog-20200320/v2
package main

import (
	"fmt"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
	videorecog20200320 "github.com/alibabacloud-go/videorecog-20200320/v2/client"
	"os"
)

func main() {
  // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
  // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
  // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.  
  accessKeyId := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")  
  accessKeySecret := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
  // Initialize the configuration object *openapi.Config. This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
  config := &openapi.Config{
    AccessKeyId: tea.String(accessKeyId),
    AccessKeySecret: tea.String(accessKeySecret)
	}
	// The service endpoint.
	config.Endpoint = tea.String("videorecog.cn-shanghai.aliyuncs.com")
	client, err := videorecog20200320.NewClient(config)
	if err != nil {
		fmt.Println(err.Error())
	}

	evaluateVideoQualityRequest := &videorecog20200320.EvaluateVideoQualityRequest{
		VideoUrl: tea.String("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4"),
	}
	runtime := &util.RuntimeOptions{}
	evaluateVideoQualityResponse, _err := client.EvaluateVideoQualityWithOptions(evaluateVideoQualityRequest, runtime)
	if _err != nil {
		fmt.Println(_err.Error())
	} else {
		// Get the complete response.
		fmt.Println(evaluateVideoQualityResponse)
		// Get a specific field from the response.
		fmt.Println(evaluateVideoQualityResponse.Body.Data)
	}
}
// Install the dependency package.
// dotnet add package AlibabaCloud.SDK.Videorecog20200320
// The minimum required SDK version for videorecog20200320 is 2.0.5.
// You can find the latest SDK version at: https://nuget.org/packages/AlibabaCloud.SDK.Videorecog20200320
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Videorecog20200320.Models;
using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample
    {
        /**
            * Initializes the client with an AccessKey ID and an AccessKey Secret.
            * @param accessKeyId
            * @param accessKeySecret
            * @return Client
            * @throws Exception
        */
        public static AlibabaCloud.SDK.Videorecog20200320.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            // Initialize the configuration object AlibabaCloud.OpenApiClient.Models.Config. This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            // The service endpoint.
            config.Endpoint = "videorecog.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Videorecog20200320.Client(config);
        }
        public static void Main(string[] args)
        {
            // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
            // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
            // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
            AlibabaCloud.SDK.Videorecog20200320.Client client = CreateClient(System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            AlibabaCloud.SDK.Videorecog20200320.Models.EvaluateVideoQualityRequest evaluateVideoQualityRequest = new AlibabaCloud.SDK.Videorecog20200320.Models.EvaluateVideoQualityRequest
            {
                VideoUrl = "https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4",
            };
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Videorecog20200320.Models.EvaluateVideoQualityResponse evaluateVideoQualityResponse = client.EvaluateVideoQualityWithOptions(evaluateVideoQualityRequest, runtime);
                // Get the complete response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(evaluateVideoQualityResponse.Body));
                // Get a specific field from the response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(evaluateVideoQualityResponse.Body.Data));
            }
            catch (TeaException error)
            {
                // Handle and print the error.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // Handle and print the error.
                Console.WriteLine(error.Message);
            }
        }
    }
}

Local file or URL

For sample code in common languages for querying the result of an asynchronous task, see Query the result of an asynchronous task.

// -*- coding: utf-8 -*-
// Import the required dependencies.
// The minimum required SDK version for videorecog20200320 is 1.0.7.
// You can find the latest SDK version at: https://mvnrepository.com/artifact/com.aliyun/videorecog20200320
// <dependency>
//       <groupId>com.aliyun</groupId>
//       <artifactId>videorecog20200320</artifactId>
//       <version>${aliyun.videorecog.version}</version>
// </dependency>

import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;
import com.aliyun.videorecog20200320.models.EvaluateVideoQualityResponse;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;

public class EvaluateVideoQuality {

    public static com.aliyun.videorecog20200320.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          Initialize the configuration object com.aliyun.teaopenapi.models.Config.
          This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
         */
         com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setAccessKeyId(accessKeyId)
                .setAccessKeySecret(accessKeySecret);
        // The service endpoint.
        config.endpoint = "videorecog.cn-shanghai.aliyuncs.com";
        return new com.aliyun.videorecog20200320.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
        // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
        String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); 
        com.aliyun.videorecog20200320.Client client = EvaluateVideoQuality.createClient(accessKeyId, accessKeySecret);
        // Scenario 1: Use a local file.
        // InputStream inputStream = new FileInputStream(new File("/tmp/EvaluateVideoQuality1.mp4"));
        // Scenario 2: Use an accessible URL.
        URL url = new URL("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4");
        InputStream inputStream = url.openConnection().getInputStream();
        com.aliyun.videorecog20200320.models.EvaluateVideoQualityAdvanceRequest evaluateVideoQualityAdvanceRequest = new com.aliyun.videorecog20200320.models.EvaluateVideoQualityAdvanceRequest()
                .setVideoUrlObject(inputStream);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Call the API and print the response.
            EvaluateVideoQualityResponse response = client.evaluateVideoQualityAdvance(evaluateVideoQualityAdvanceRequest, runtime);
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));
        } catch (TeaException error) {
            // Get the complete error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(error));
            // Get a specific field from the error.
            System.out.println(error.getCode());
        }
    }
}
# -*- coding: utf-8 -*-
# Import the required dependencies.
# The minimum required SDK version for videorecog20200320 is 3.0.6.
# You can find the latest SDK version at: https://pypi.org/project/alibabacloud-videorecog20200320/
# pip install alibabacloud_videorecog20200320

import os
import io
from urllib.request import urlopen
from alibabacloud_tea_openapi.models import Config
from alibabacloud_tea_util.models import RuntimeOptions
from alibabacloud_videorecog20200320.client import Client
from alibabacloud_videorecog20200320.models import EvaluateVideoQualityAdvanceRequest

config = Config(
  # For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
  # If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
  # Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
  access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'),
  access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
  # The service endpoint.
  endpoint='videorecog.cn-shanghai.aliyuncs.com',
  # The ID of the region where the service is deployed.
  region_id='cn-shanghai'
)
# Scenario 1: Use a local file.
#img = open(r'/tmp/EvaluateVideoQuality1.mp4', 'rb')
# Scenario 2: Use an accessible URL.
url = 'https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4'
img = io.BytesIO(urlopen(url).read())
evaluate_video_quality_request = EvaluateVideoQualityAdvanceRequest()
evaluate_video_quality_request.video_url_object = img
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.evaluate_video_quality_advance(evaluate_video_quality_request, runtime)
  # Get the complete response.
  print(response.body)
except Exception as error:
  # Get the complete error message.
  print(error)
  # Get a specific field from the error.
  print(error.code)
<?php

// Install the dependency package.
// The minimum required SDK version for videorecog-20200320 is 1.0.8.
// You can find the latest SDK version at: https://packagist.org/packages/alibabacloud/videorecog-20200320
// composer require alibabacloud/videorecog-20200320

use AlibabaCloud\SDK\Videorecog\V20200320\Videorecog;
use \Exception;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Videorecog\V20200320\Models\EvaluateVideoQualityAdvanceRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use GuzzleHttp\Psr7\Stream;

class EvaluateVideoQualityAdvance {

    /**
     * Initializes the client with an AccessKey ID and an AccessKey Secret.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Videorecog Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        // Initialize the configuration object Darabonba\OpenApi\Models\Config.
        // This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
        $config = new Config([
            "accessKeyId" => $accessKeyId,
            "accessKeySecret" => $accessKeySecret
        ]);
        // The service endpoint.
        $config->endpoint = "videorecog.cn-shanghai.aliyuncs.com";
        return new Videorecog($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
        // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
        // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
        $accessKeyId = getenv('ALIBABA_CLOUD_ACCESS_KEY_ID');
        $accessKeySecret = getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'); 
        $client = self::createClient($accessKeyId, $accessKeySecret);
        // Scenario 1: Use a local file.
        //$file = fopen('/tmp/EvaluateVideoQuality1.mp4', 'rb');
        //$stream = new Stream($file);
        // Scenario 2: Use an accessible URL.
        $file = fopen('https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4', 'rb');
        $stream = new Stream($file);
        $evaluateVideoQualityAdvanceRequest = new EvaluateVideoQualityAdvanceRequest([
            "videoUrlObject" => $stream
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->evaluateVideoQualityAdvance($evaluateVideoQualityAdvanceRequest, $runtime);
            # Get the complete response.
            echo Utils::toJSONString($resp->body);
        } catch (Exception $exception) {
            # Get the complete error message.
            echo Utils::toJSONString($exception);
            # Get a specific field from the error.
            echo $exception->getCode();
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
// $argv is a reserved array for input parameters and should not be modified.
EvaluateVideoQualityAdvance::main(array_slice($argv, 1));
// Install the dependency package.
// npm install @alicloud/videorecog20200320
// The minimum required SDK version for videorecog20200320 is 3.0.5.
// You can find the latest SDK version at: https://npmjs.com/package/@alicloud/videorecog20200320
const VideorecogClient = require('@alicloud/videorecog20200320');
const OpenapiClient = require('@alicloud/openapi-client');
const TeaUtil = require('@alicloud/tea-util');
const fs = require('fs');
const http = require('http');
const https = require('https');

let config = new OpenapiClient.Config({
  // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
  // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
  // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code. 
  accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,   
  accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET
});
// The service endpoint.
config.endpoint = `videorecog.cn-shanghai.aliyuncs.com`;
const client = new VideorecogClient.default(config);
const getResponse = function (httpClient, url) {
  return new Promise((resolve, reject) => {
    httpClient.get(url, function (response) {
      resolve(response);
    })
  })
}
const request = async function () {
  try {
    let evaluateVideoQualityAdvanceRequest = new VideorecogClient.EvaluateVideoQualityAdvanceRequest();
    // Scenario 1: Use a local file.
    // const fileStream = fs.createReadStream('/tmp/EvaluateVideoQuality1.mp4');
    // evaluateVideoQualityAdvanceRequest.videoUrlObject = fileStream;
    // Scenario 2: Use an accessible URL.
    const url = new URL("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4");
    const httpClient = (url.protocol == "https:") ? https : http;
    evaluateVideoQualityAdvanceRequest.videoUrlObject = await getResponse(httpClient, url);
    let runtime = new TeaUtil.RuntimeOptions({ });
    client.evaluateVideoQualityAdvance(evaluateVideoQualityAdvanceRequest, runtime)
      .then(function(evaluateVideoQualityResponse) {
        // Get the complete response.
        console.log(evaluateVideoQualityResponse);
        // Get a specific field from the response.
        console.log(evaluateVideoQualityResponse.body.data);
      }, function(error) {
        // Get the complete error message.
        console.log(error);
        // Get a specific field from the error.
        console.log(error.data.Code);
      })
  } catch (error) {
    console.log(error);
  }
}();
// -*- coding: utf-8 -*-
// Import the required dependencies.
// The minimum required SDK version for videoenhan20190930 is 2.0.7.
// You can find the latest SDK version at: https://pkg.go.dev/github.com/alibabacloud-go/videorecog-20200320/v2
// go get github.com/alibabacloud-go/videorecog-20200320/v2
package main

import (
	"fmt"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
	videorecog20200320 "github.com/alibabacloud-go/videorecog-20200320/v2/client"
	"net/http"
	"os"
)

func main() {
  // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
  // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
  // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.  
  accessKeyId := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")  
  accessKeySecret := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")
  // Initialize the configuration object *openapi.Config. This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
  config := &openapi.Config{
    AccessKeyId: tea.String(accessKeyId),
    AccessKeySecret: tea.String(accessKeySecret)
	}
	// The service endpoint.
	config.Endpoint = tea.String("videorecog.cn-shanghai.aliyuncs.com")
	client, err := videorecog20200320.NewClient(config)
	if err != nil {
		fmt.Println(err.Error())
	}
	// Scenario 1: Use a local file.
	//file, err := os.Open("/tmp/EvaluateVideoQuality1.mp4")
	//if err != nil {
	//	fmt.Println("can not open file", err)
	//}
	//evaluateVideoQualityAdvanceRequest := &videorecog20200320.EvaluateVideoQualityAdvanceRequest{
	//	VideoUrlObject: file,
	//}
	// Scenario 2: Use an accessible URL.
	httpClient := http.Client{}
	file1, _ := httpClient.Get("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4")
	evaluateVideoQualityAdvanceRequest := &videorecog20200320.EvaluateVideoQualityAdvanceRequest{
		VideoUrlObject: file1.Body,
	}
	runtime := &util.RuntimeOptions{}
	evaluateVideoQualityResponse, _err := client.EvaluateVideoQualityAdvance(evaluateVideoQualityAdvanceRequest, runtime)
	if _err != nil {
		fmt.Println(_err.Error())
	} else {
		// Get the complete response.
		fmt.Println(evaluateVideoQualityResponse)
		// Get a specific field from the response.
		fmt.Println(evaluateVideoQualityResponse.Body.Data)
	}
}
// Install the dependency package.
// dotnet add package AlibabaCloud.SDK.Videorecog20200320
// The minimum required SDK version for videorecog20200320 is 2.0.5.
// You can find the latest SDK version at: https://nuget.org/packages/AlibabaCloud.SDK.Videorecog20200320
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Videorecog20200320.Models;
using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample
    {
        /**
            * Initializes the client with an AccessKey ID and an AccessKey Secret.
            * @param accessKeyId
            * @param accessKeySecret
            * @return Client
            * @throws Exception
        */
        public static AlibabaCloud.SDK.Videorecog20200320.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            // Initialize the configuration object AlibabaCloud.OpenApiClient.Models.Config. This object stores configurations such as your AccessKey ID, AccessKey Secret, and endpoint.
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            // The service endpoint.
            config.Endpoint = "videorecog.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Videorecog20200320.Client(config);
        }
        public static void Main(string[] args)
        {
            // For more information about how to create an AccessKey ID and an AccessKey Secret, see https://help.aliyun.com/document_detail/175144.html.
            // If you use the AccessKey of a RAM user, you must grant the AliyunVIAPIFullAccess permission to the RAM user. For more information, see https://help.aliyun.com/document_detail/145025.html.
            // Retrieve the AccessKey ID and AccessKey Secret from environment variables. You must configure these variables before running the code.
            AlibabaCloud.SDK.Videorecog20200320.Client client = CreateClient(System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            AlibabaCloud.SDK.Videorecog20200320.Models.EvaluateVideoQualityAdvanceRequest evaluateVideoQualityAdvanceRequest = new AlibabaCloud.SDK.Videorecog20200320.Models.EvaluateVideoQualityAdvanceRequest
            ();
            // Scenario 1: Use a local file.
            // System.IO.StreamReader file = new System.IO.StreamReader(@"/tmp/EvaluateVideoQuality1.mp4");
            // evaluateVideoQualityAdvanceRequest.VideoUrlObject = file.BaseStream;

            // Scenario 2: Use an accessible URL.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videorecog/EvaluateVideoQuality/EvaluateVideoQuality1.mp4");
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            evaluateVideoQualityAdvanceRequest.VideoUrlObject = stream;

            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Videorecog20200320.Models.EvaluateVideoQualityResponse evaluateVideoQualityResponse = client.EvaluateVideoQualityAdvance(evaluateVideoQualityAdvanceRequest, runtime);
                // Get the complete response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(evaluateVideoQualityResponse.Body));
                // Get a specific field from the response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(evaluateVideoQualityResponse.Body.Data));
            }
            catch (TeaException error)
            {
                // Handle and print the error.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // Handle and print the error.
                Console.WriteLine(error.Message);
            }
        }
    }
}