AddFaceVideoTemplate

Updated at:

This document provides sample code for the AddFaceVideoTemplate operation in popular 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.

Overview

For a functional overview and detailed parameter descriptions of the AddFaceVideoTemplate operation, see AddFaceVideoTemplate.

Install the SDK package

For SDK dependencies for popular 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

For sample code in popular languages for querying asynchronous task results, see Query asynchronous task results.

/*
Add the dependency package.
<!-- https://mvnrepository.com/artifact/com.aliyun/videoenhan20200320 -->
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>videoenhan20200320</artifactId>
  <version>${aliyun.videoenhan.version}</version>
</dependency>
*/

import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;
import com.aliyun.videoenhan20200320.models.AddFaceVideoTemplateResponse;

public class AddFaceVideoTemplate {
    public static com.aliyun.videoenhan20200320.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 endpoint of the service.
        config.endpoint = "videoenhan.cn-shanghai.aliyuncs.com";
        return new com.aliyun.videoenhan20200320.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // For 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.
        // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
        String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); 
        com.aliyun.videoenhan20200320.Client client = AddFaceVideoTemplate.createClient(accessKeyId, accessKeySecret);
        com.aliyun.videoenhan20200320.models.AddFaceVideoTemplateRequest addFaceVideoTemplateRequest = new com.aliyun.videoenhan20200320.models.AddFaceVideoTemplateRequest()
                .setVideoURL("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            AddFaceVideoTemplateResponse addFaceVideoTemplateResponse = client.addFaceVideoTemplateWithOptions(addFaceVideoTemplateRequest, runtime);
            // Obtain the full response.
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(addFaceVideoTemplateResponse)));
            // Obtain a specific field.
            System.out.println(addFaceVideoTemplateResponse.getBody());
        } catch (TeaException teaException) {
            // Obtain the full error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
            // Obtain a specific field.
            System.out.println(teaException.getCode());
        }
    }
}
# -*- coding: utf-8 -*-
# Add the dependency package.
# pip install alibabacloud_videoenhan20200320

import os
from alibabacloud_tea_openapi.models import Config
from alibabacloud_tea_util.models import RuntimeOptions
from alibabacloud_videoenhan20200320.client import Client
from alibabacloud_videoenhan20200320.models import AddFaceVideoTemplateRequest

config = Config(
  # For 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.
  # Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
  access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'),
  access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
  # The endpoint of the service.
  endpoint='videoenhan.cn-shanghai.aliyuncs.com',
  # The region ID that corresponds to the endpoint.
  region_id='cn-shanghai'
)
add_face_video_template_request = AddFaceVideoTemplateRequest(
    video_url='https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4'
)
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.add_face_video_template_with_options(add_face_video_template_request, runtime)
  # Obtain the full response.
  print(response.body)
except Exception as error:
  # Obtain the full error message.
  print(error)
  # Obtain a specific field.
  print(error.code)
<?php

// Install the dependency package.
//composer require alibabacloud/videoenhan-20200320

use AlibabaCloud\SDK\Videoenhan\V20200320\Videoenhan;
use \Exception;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Videoenhan\V20200320\Models\AddFaceVideoTemplateRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class AddFaceVideoTemplate {

    /**
     * Initialize the client by using an AccessKey ID and an AccessKey Secret.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Videoenhan 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 endpoint of the service.
        $config->endpoint = "videoenhan.cn-shanghai.aliyuncs.com";
        return new Videoenhan($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        // For 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.
        // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
        $accessKeyId = getenv('ALIBABA_CLOUD_ACCESS_KEY_ID');
        $accessKeySecret = getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'); 
        $client = self::createClient($accessKeyId, $accessKeySecret);
        $addFaceVideoTemplateRequest = new AddFaceVideoTemplateRequest([
            "videoURL" => "https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4"
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->addFaceVideoTemplateWithOptions($addFaceVideoTemplateRequest, $runtime);
            # Obtain the full response.
            echo Utils::toJSONString($resp->body);
        } catch (Exception $exception) {
            # Obtain the full error message.
            echo Utils::toJSONString($exception);
            # Obtain a specific field.
            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 does not need to be modified.
AddFaceVideoTemplate::main(array_slice($argv, 1));
// Install the dependency package.
// npm install @alicloud/videoenhan20200320
const VideoenhanClient = require('@alicloud/videoenhan20200320');
const OpenapiClient = require('@alicloud/openapi-client');
const TeaUtil = require('@alicloud/tea-util');

let config = new OpenapiClient.Config({
  // For 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.
  // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code. 
  accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,   
  accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET
});
// The endpoint of the service.
config.endpoint = `videoenhan.cn-shanghai.aliyuncs.com`;
const client = new VideoenhanClient.default(config);
let addFaceVideoTemplateRequest = new VideoenhanClient.AddFaceVideoTemplateRequest({
  videoURL: "https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4",
});
let runtime = new TeaUtil.RuntimeOptions({});
client.addFaceVideoTemplateWithOptions(addFaceVideoTemplateRequest, runtime)
  .then(function (addFaceVideoTemplateResponse) {
    // Obtain the full response.
    console.log(addFaceVideoTemplateResponse);
    // Obtain a specific field.
    console.log(addFaceVideoTemplateResponse.body.data);
  }, function (error) {
    // Obtain the full error message.
    console.log(error);
    // Obtain a specific field.
    console.log(error.data.Code);
  })
// Add the dependency github.com/alibabacloud-go/videoenhan-20200320/v3.
// We recommend that you run the 'go mod tidy' command to install the dependency.

package main

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

func main() {  
  // For 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.
  // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample 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 endpoint of the service.
	config.Endpoint = tea.String("videoenhan.cn-shanghai.aliyuncs.com")
	client, err := videoenhan20200320.NewClient(config)
	if err != nil {
		panic(err)
	}
	addFaceVideoTemplateRequest := &videoenhan20200320.AddFaceVideoTemplateRequest{
		VideoURL: tea.String("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4"),
	}
	runtime := &util.RuntimeOptions{}
	addFaceVideoTemplateResponse, err := client.AddFaceVideoTemplateWithOptions(addFaceVideoTemplateRequest, runtime)
	if err != nil {
		// Obtain the full error message.
		fmt.Println(err.Error())
	} else {
		// Obtain the full response.
		fmt.Println(addFaceVideoTemplateResponse)
	}
}
// Install the dependency package.
// dotnet add package AlibabaCloud.SDK.Videoenhan20200320
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Videoenhan20200320.Models;
using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample
    {
        /**
            * Initialize the client by using an AccessKey ID and an AccessKey Secret.
            * @param accessKeyId
            * @param accessKeySecret
            * @return Client
            * @throws Exception
        */
        public static AlibabaCloud.SDK.Videoenhan20200320.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            // The endpoint of the service.
            config.Endpoint = "videoenhan.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Videoenhan20200320.Client(config);
        }
        public static void Main(string[] args)
        {
            // For 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.
            // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
            AlibabaCloud.SDK.Videoenhan20200320.Client client = CreateClient(System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            AlibabaCloud.SDK.Videoenhan20200320.Models.AddFaceVideoTemplateRequest addFaceVideoTemplateRequest = new AlibabaCloud.SDK.Videoenhan20200320.Models.AddFaceVideoTemplateRequest
            {
                VideoURL = "https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4",
            };
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Videoenhan20200320.Models.AddFaceVideoTemplateResponse addFaceVideoTemplateResponse = client.AddFaceVideoTemplateWithOptions(addFaceVideoTemplateRequest, runtime);
                // Obtain the full response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(addFaceVideoTemplateResponse.Body));
            }
            catch (TeaException error)
            {
                // If an error occurs, print the error message.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // If an error occurs, print the error message.
                Console.WriteLine(error.Message);
            }
        }
    }
}

File from a local path or URL

For sample code in popular languages for querying asynchronous task results, see Query asynchronous task results.

/*
Add the dependency package.
<!-- https://mvnrepository.com/artifact/com.aliyun/videoenhan20200320 -->
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>videoenhan20200320</artifactId>
  <version>${aliyun.videoenhan.version}</version>
</dependency>
*/

import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;
import com.aliyun.videoenhan20200320.models.AddFaceVideoTemplateResponse;

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

public class AddFaceVideoTemplate {
    public static com.aliyun.videoenhan20200320.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 endpoint of the service.
        config.endpoint = "videoenhan.cn-shanghai.aliyuncs.com";
        return new com.aliyun.videoenhan20200320.Client(config);
    }

    public static void main(String[] args) throws Exception {
        // For 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.
        // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
        String accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
        String accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"); 
        com.aliyun.videoenhan20200320.Client client = AddFaceVideoTemplate.createClient(accessKeyId, accessKeySecret);
        // Scenario 1: Use a local file.
        // InputStream inputStream = new FileInputStream(new File("/tmp/AddFaceVideoTemplate1.mp4"));
        // Scenario 2: Use an accessible URL.
        URL url = new URL("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4");
        InputStream inputStream = url.openConnection().getInputStream();
        com.aliyun.videoenhan20200320.models.AddFaceVideoTemplateAdvanceRequest addFaceVideoTemplateAdvanceRequest = new com.aliyun.videoenhan20200320.models.AddFaceVideoTemplateAdvanceRequest()
                .setVideoURLObject(inputStream);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            AddFaceVideoTemplateResponse addFaceVideoTemplateAdvanceResponse = client.addFaceVideoTemplateAdvance(addFaceVideoTemplateAdvanceRequest, runtime);
            // Obtain the full response.
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(addFaceVideoTemplateAdvanceResponse)));
            // Obtain a specific field.
            System.out.println(addFaceVideoTemplateAdvanceResponse.getBody());
        } catch (TeaException teaException) {
            // Obtain the full error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
            // Obtain a specific field.
            System.out.println(teaException.getCode());
        }
    }
}
# -*- coding: utf-8 -*-
# Add the dependency package.
# pip install alibabacloud_videoenhan20200320

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_videoenhan20200320.client import Client
from alibabacloud_videoenhan20200320.models import AddFaceVideoTemplateAdvanceRequest

config = Config(
  # For 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.
  # Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
  access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID'),
  access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),
  # The endpoint of the service.
  endpoint='videoenhan.cn-shanghai.aliyuncs.com',
  # The region ID that corresponds to the endpoint.
  region_id='cn-shanghai'
)
# Scenario 1: Use a local file.
#img = open(r'/tmp/AddFaceVideoTemplate1.mp4', 'rb')
# Scenario 2: Use an accessible URL.
url = 'https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4'
img = io.BytesIO(urlopen(url).read())
add_face_video_template_request = AddFaceVideoTemplateAdvanceRequest()
add_face_video_template_request.video_urlobject = img
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.add_face_video_template_advance(add_face_video_template_request, runtime)
  # Obtain the full response.
  print(response.body)
except Exception as error:
  # Obtain the full error message.
  print(error)
  # Obtain a specific field.
  print(error.code)
<?php

// Install the dependency package.
//composer require alibabacloud/videoenhan-20200320

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

class AddFaceVideoTemplateAdvance {

    /**
     * Initialize the client by using an AccessKey ID and an AccessKey Secret.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Videoenhan 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 endpoint of the service.
        $config->endpoint = "videoenhan.cn-shanghai.aliyuncs.com";
        return new Videoenhan($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        // For 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.
        // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample 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/AddFaceVideoTemplate1.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/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4', 'rb');
        $stream = new Stream($file);
        $addFaceVideoTemplateAdvanceRequest = new AddFaceVideoTemplateAdvanceRequest([
            "videoURLObject" => $stream
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->addFaceVideoTemplateAdvance($addFaceVideoTemplateAdvanceRequest, $runtime);
            # Obtain the full response.
            echo Utils::toJSONString($resp->body);
        } catch (Exception $exception) {
            # Obtain the full error message.
            echo Utils::toJSONString($exception);
            # Obtain a specific field.
            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 does not need to be modified.
AddFaceVideoTemplateAdvance::main(array_slice($argv, 1));
// Install the dependency package.
// npm install @alicloud/videoenhan20200320
const VideoenhanClient = require('@alicloud/videoenhan20200320');
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 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.
  // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code. 
  accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,   
  accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET
});
// The endpoint of the service.
config.endpoint = `videoenhan.cn-shanghai.aliyuncs.com`;
const client = new VideoenhanClient.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 addFaceVideoTemplateAdvanceRequest = new VideoenhanClient.AddFaceVideoTemplateAdvanceRequest();
    // Scenario 1: Use a local file.
    // const fileStream = fs.createReadStream('/tmp/AddFaceVideoTemplate1.mp4');
    // addFaceVideoTemplateAdvanceRequest.videoURLObject = fileStream;
    // Scenario 2: Use an accessible URL.
    const url = new URL("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4");
    const httpClient = (url.protocol == "https:") ? https : http;
    addFaceVideoTemplateAdvanceRequest.videoURLObject = await getResponse(httpClient, url);
    let runtime = new TeaUtil.RuntimeOptions({ });
    client.addFaceVideoTemplateAdvance(addFaceVideoTemplateAdvanceRequest, runtime)
      .then(function(addFaceVideoTemplateResponse) {
        // Obtain the full response.
        console.log(addFaceVideoTemplateResponse);
        // Obtain a specific field.
        console.log(addFaceVideoTemplateResponse.body.data);
      }, function(error) {
        // Obtain the full error message.
        console.log(error);
        // Obtain a specific field.
        console.log(error.data.Code);
      })
  } catch (error) {
    console.log(error);
  }
}();
// Add the dependency github.com/alibabacloud-go/videoenhan-20200320/v3.
// We recommend that you run the 'go mod tidy' command to install the dependency.

package main

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

func main() {  
  // For 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.
  // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample 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 endpoint of the service.
	config.Endpoint = tea.String("videoenhan.cn-shanghai.aliyuncs.com")
	client, err := videoenhan20200320.NewClient(config)
	if err != nil {
		panic(err)
	}
	// Scenario 1: Use a local file.
	//file, err := os.Open("/tmp/AddFaceVideoTemplate1.mp4")
	//if err != nil {
	//	fmt.Println("can not open file", err)
	//	panic(err)
	//}
	//addFaceVideoTemplateAdvanceRequest := &videoenhan20200320.AddFaceVideoTemplateAdvanceRequest{
	//	VideoURLObject: file,
	//}
	// Scenario 2: Use an accessible URL.
	httpClient := http.Client{}
	file, _ := httpClient.Get("https://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4")
	addFaceVideoTemplateAdvanceRequest := &videoenhan20200320.AddFaceVideoTemplateAdvanceRequest{
		VideoURLObject: file.Body,
	}
	runtime := &util.RuntimeOptions{}
	addFaceVideoTemplateAdvanceResponse, err := client.AddFaceVideoTemplateAdvance(addFaceVideoTemplateAdvanceRequest, runtime)
	if err != nil {
		// Obtain the full error message.
		fmt.Println(err.Error())
	} else {
		// Obtain the full response.
		fmt.Println(addFaceVideoTemplateAdvanceResponse)
	}
}
// Install the dependency package.
// dotnet add package AlibabaCloud.SDK.Videoenhan20200320
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using AlibabaCloud.SDK.Videoenhan20200320.Models;
using Tea;
using Tea.Utils;

namespace AlibabaCloud.SDK.Sample
{
    public class Sample
    {
        /**
            * Initialize the client by using an AccessKey ID and an AccessKey Secret.
            * @param accessKeyId
            * @param accessKeySecret
            * @return Client
            * @throws Exception
        */
        public static AlibabaCloud.SDK.Videoenhan20200320.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                AccessKeyId = accessKeyId,
                AccessKeySecret = accessKeySecret,
            };
            // The endpoint of the service.
            config.Endpoint = "videoenhan.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Videoenhan20200320.Client(config);
        }
        public static void Main(string[] args)
        {
            // For 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.
            // Read the AccessKey ID and AccessKey Secret from environment variables. You must configure the environment variables before running the sample code.
            AlibabaCloud.SDK.Videoenhan20200320.Client client = CreateClient(System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID"), System.Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
            AlibabaCloud.SDK.Videoenhan20200320.Models.AddFaceVideoTemplateAdvanceRequest addFaceVideoTemplateAdvanceRequest = new AlibabaCloud.SDK.Videoenhan20200320.Models.AddFaceVideoTemplateAdvanceRequest
            ();
            // Scenario 1: Use a local file.
            // System.IO.StreamReader file = new System.IO.StreamReader(@"/tmp/AddFaceVideoTemplate1.mp4");
            // addFaceVideoTemplateAdvanceRequest.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/videoenhan/AddFaceVideoTemplate/AddFaceVideoTemplate1.mp4");
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            addFaceVideoTemplateAdvanceRequest.VideoURLObject = stream;
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Videoenhan20200320.Models.AddFaceVideoTemplateResponse addFaceVideoTemplateResponse = client.AddFaceVideoTemplateAdvance(addFaceVideoTemplateAdvanceRequest, runtime);
                // Obtain the full response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(addFaceVideoTemplateResponse.Body));
            }
            catch (TeaException error)
            {
                // If an error occurs, print the error message.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // If an error occurs, print the error message.
                Console.WriteLine(error.Message);
            }
        }
    }
}