Erase video subtitles

Updated at:

This topic provides code examples for using Erase Video Subtitles in several common programming languages.

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 a detailed description of the feature and its parameters, see Erase Video Subtitles.

Install the SDK

For information about the SDK dependencies for popular programming languages, see SDKs.

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.

Code examples

File in OSS (Shanghai)

For code examples on how to query the results of an asynchronous task, see Query the results of an asynchronous task.

/*
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.EraseVideoSubtitlesResponse;

public class EraseVideoSubtitles {
    public static com.aliyun.videoenhan20200320.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          Initialize the 'Config' object, which 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 on how to create an AccessKey ID and 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 you run 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 = EraseVideoSubtitles.createClient(accessKeyId, accessKeySecret);
        com.aliyun.videoenhan20200320.models.EraseVideoSubtitlesRequest eraseVideoSubtitlesRequest = new com.aliyun.videoenhan20200320.models.EraseVideoSubtitlesRequest()
                .setVideoUrl("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            EraseVideoSubtitlesResponse eraseVideoSubtitlesResponse = client.eraseVideoSubtitlesWithOptions(eraseVideoSubtitlesRequest, runtime);
            // Get the full response.
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(eraseVideoSubtitlesResponse)));
            // Get a specific field from the response.
            System.out.println(eraseVideoSubtitlesResponse.getBody());
        } catch (TeaException teaException) {
            // Get the complete error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
            // Get a specific field from the error.
            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 EraseVideoSubtitlesRequest

config = Config(
    # For information on how to create an AccessKey ID and 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 you run 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'
)
erase_video_subtitles_request = EraseVideoSubtitlesRequest(
   video_url='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4',
   by=0.5,
   bw=0.25,
   bh=0.25,
   bx=0.2
)
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.erase_video_subtitles_with_options(erase_video_subtitles_request, runtime)
  # Get the full 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

// Add 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\EraseVideoSubtitlesRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class EraseVideoSubtitles {

    /**
     * Initialize the client with the AccessKey pair.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Videoenhan Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        // Initialize the configuration object Darabonba\OpenApi\Models\Config.
        // The Config object stores configurations such as accessKeyId, accessKeySecret, 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 on how to create an AccessKey ID and 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 you run the sample code.    
        $accessKeyId = getenv('ALIBABA_CLOUD_ACCESS_KEY_ID');      
        $accessKeySecret = getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
        $client = self::createClient($accessKeyId, $accessKeySecret);
        $eraseVideoSubtitlesRequest = new EraseVideoSubtitlesRequest([
            "videoUrl" => "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4",
            "BY" => 0.5,
            "BW" => 0.25,
            "BH" => 0.25,
            "BX" => 0.2
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->eraseVideoSubtitlesWithOptions($eraseVideoSubtitlesRequest, $runtime);
            # Get the full 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;
}
// The $argv parameter is reserved and has no actual meaning. You do not need to modify it.
EraseVideoSubtitles::main(array_slice($argv, 1));
// Add 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 on how to create an AccessKey ID and 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 you run 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 eraseVideoSubtitlesRequest = new VideoenhanClient.EraseVideoSubtitlesRequest({
  videoUrl: "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4",
});
let runtime = new TeaUtil.RuntimeOptions({});
client.eraseVideoSubtitlesWithOptions(eraseVideoSubtitlesRequest, runtime)
  .then(function (eraseVideoSubtitlesResponse) {
    // Get the full response.
    console.log(eraseVideoSubtitlesResponse);
    // Get a specific field from the response.
    console.log(eraseVideoSubtitlesResponse.body.data);
  }, function (error) {
    // Get the complete error message.
    console.log(error);
    // Get a specific field from the error.
    console.log(error.data.Code);
  })
/**
Add the dependency from 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 on how to create an AccessKey ID and 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 you run 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. The Config object stores configurations such as AccessKeyId, AccessKeySecret, 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)
	}
	eraseVideoSubtitlesRequest := &videoenhan20200320.EraseVideoSubtitlesRequest{
		VideoUrl: tea.String("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4"),
	}
	runtime := &util.RuntimeOptions{}
	eraseVideoSubtitlesResponse, err := client.EraseVideoSubtitlesWithOptions(eraseVideoSubtitlesRequest, runtime)
	if err != nil {
		// Get the complete error message.
		fmt.Println(err.Error())
	} else {
		// Get the full response.
		fmt.Println(eraseVideoSubtitlesResponse)
	}
}
// Add the dependency package.
// dotnet add package AlibabaCloud.SDK.Videoenhan20200320
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
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 with the AccessKey pair.
            * @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 on how to create an AccessKey ID and 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 you run 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.EraseVideoSubtitlesRequest eraseVideoSubtitlesRequest = new AlibabaCloud.SDK.Videoenhan20200320.Models.EraseVideoSubtitlesRequest
            {
                VideoUrl = "http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4",
            };
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Videoenhan20200320.Models.EraseVideoSubtitlesResponse eraseVideoSubtitlesResponse = client.EraseVideoSubtitlesWithOptions(eraseVideoSubtitlesRequest, runtime);
                // Get the full response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(eraseVideoSubtitlesResponse.Body));
                // Get a specific field from the response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(eraseVideoSubtitlesResponse.Body.Data));
            }
            catch (TeaException error)
            {
                // If necessary, print the error.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // If necessary, print the error.
                Console.WriteLine(error.Message);
            }
        }
    }
}

Local file or public URL

For code examples on how to query the results of an asynchronous task, see Query the results of an asynchronous task.

/*
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.EraseVideoSubtitlesResponse;

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

public class EraseVideoSubtitles {
    public static com.aliyun.videoenhan20200320.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        /*
          Initialize the 'Config' object, which 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 on how to create an AccessKey ID and 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 you run 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 = EraseVideoSubtitles.createClient(accessKeyId, accessKeySecret);
        // Scenario 1: Use a local file.
        // InputStream inputStream = new FileInputStream(new File("/tmp/EraseVideoSubtitles1.mp4"));
        // Scenario 2: Use a publicly accessible URL.
        URL url = new URL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4");
        InputStream inputStream = url.openConnection().getInputStream();
        com.aliyun.videoenhan20200320.models.EraseVideoSubtitlesAdvanceRequest eraseVideoSubtitlesAdvanceRequest = new com.aliyun.videoenhan20200320.models.EraseVideoSubtitlesAdvanceRequest()
                .setVideoUrlObject(inputStream);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            EraseVideoSubtitlesResponse eraseVideoSubtitlesAdvanceResponse = client.eraseVideoSubtitlesAdvance(eraseVideoSubtitlesAdvanceRequest, runtime);
            // Get the full response.
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(eraseVideoSubtitlesAdvanceResponse)));
            // Get a specific field from the response.
            System.out.println(eraseVideoSubtitlesAdvanceResponse.getBody());
        } catch (TeaException teaException) {
            // Get the complete error message.
            System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
            // Get a specific field from the error.
            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 EraseVideoSubtitlesAdvanceRequest

config = Config(
    # For information on how to create an AccessKey ID and 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 you run 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/EraseVideoSubtitles1.mp4', 'rb')
# Scenario 2: Use a publicly accessible URL.
url = 'http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4'
img = io.BytesIO(urlopen(url).read())
erase_video_subtitles_request = EraseVideoSubtitlesAdvanceRequest(
   video_url_object=img,
   by=0.5,
   bw=0.25,
   bh=0.25,
   bx=0.2
)
runtime = RuntimeOptions()
try:
  # Initialize the client.
  client = Client(config)
  response = client.erase_video_subtitles_advance(erase_video_subtitles_request, runtime)
  # Get the full 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

// Add 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\EraseVideoSubtitlesAdvanceRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use GuzzleHttp\Psr7\Stream;

class EraseVideoSubtitlesAdvance {

    /**
     * Initialize the client with the AccessKey pair.
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Videoenhan Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        // Initialize the configuration object Darabonba\OpenApi\Models\Config.
        // The Config object stores configurations such as accessKeyId, accessKeySecret, 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 on how to create an AccessKey ID and 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 you run 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/EraseVideoSubtitles1.mp4', 'rb');
        //$stream = new Stream($file);
        // Scenario 2: Use a publicly accessible URL.
        $file = fopen('http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4', 'rb');
        $stream = new Stream($file);
        $eraseVideoSubtitlesAdvanceRequest = new EraseVideoSubtitlesAdvanceRequest([
            "videoUrlObject" => $stream,
            "BY" => 0.5,
            "BW" => 0.25,
            "BH" => 0.25,
            "BX" => 0.2
        ]);
        $runtime = new RuntimeOptions([]);
        try {
            $resp = $client->eraseVideoSubtitlesAdvance($eraseVideoSubtitlesAdvanceRequest, $runtime);
            # Get the full 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;
}
// The $argv parameter is reserved and has no actual meaning. You do not need to modify it.
EraseVideoSubtitlesAdvance::main(array_slice($argv, 1));
// Add 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 on how to create an AccessKey ID and 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 you run 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 eraseVideoSubtitlesAdvanceRequest = new VideoenhanClient.EraseVideoSubtitlesAdvanceRequest();
    // Scenario 1: Use a local file.
    // const fileStream = fs.createReadStream('/tmp/EraseVideoSubtitles1.mp4');
    // eraseVideoSubtitlesAdvanceRequest.videoUrlObject = fileStream;
    // Scenario 2: Use a publicly accessible URL.
    const url = new URL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4");
    const httpClient = (url.protocol == "https:") ? https : http;
    eraseVideoSubtitlesAdvanceRequest.videoUrlObject = await getResponse(httpClient, url);
    let runtime = new TeaUtil.RuntimeOptions({ });
    client.eraseVideoSubtitlesAdvance(eraseVideoSubtitlesAdvanceRequest, runtime)
      .then(function(eraseVideoSubtitlesResponse) {
        // Get the full response.
        console.log(eraseVideoSubtitlesResponse);
        // Get a specific field from the response.
        console.log(eraseVideoSubtitlesResponse.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);
  }
}();
/**
Add the dependency from 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 on how to create an AccessKey ID and 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 you run 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. The Config object stores configurations such as AccessKeyId, AccessKeySecret, 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/EraseVideoSubtitles1.mp4")
	//if err != nil {
	//	fmt.Println("can not open file", err)
	//	panic(err)
	//}
	//eraseVideoSubtitlesAdvanceRequest := &videoenhan20200320.EraseVideoSubtitlesAdvanceRequest{
	//	VideoUrlObject: file,
	//}
	// Scenario 2: Use a publicly accessible URL.
	httpClient := http.Client{}
	file, _ := httpClient.Get("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4")
	eraseVideoSubtitlesAdvanceRequest := &videoenhan20200320.EraseVideoSubtitlesAdvanceRequest{
		VideoUrlObject: file.Body,
	}
	runtime := &util.RuntimeOptions{}
	eraseVideoSubtitlesAdvanceResponse, err := client.EraseVideoSubtitlesAdvance(eraseVideoSubtitlesAdvanceRequest, runtime)
	if err != nil {
		// Get the complete error message.
		fmt.Println(err.Error())
	} else {
		// Get the full response.
		fmt.Println(eraseVideoSubtitlesAdvanceResponse)
	}
}
// Add the dependency package.
// dotnet add package AlibabaCloud.SDK.Videoenhan20200320
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
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 with the AccessKey pair.
            * @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 on how to create an AccessKey ID and 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 you run 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.EraseVideoSubtitlesAdvanceRequest eraseVideoSubtitlesAdvanceRequest = new AlibabaCloud.SDK.Videoenhan20200320.Models.EraseVideoSubtitlesAdvanceRequest
            ();
            // Scenario 1: Use a local file.
            // System.IO.StreamReader file = new System.IO.StreamReader(@"/tmp/EraseVideoSubtitles1.mp4");
            // eraseVideoSubtitlesAdvanceRequest.VideoUrlObject = file.BaseStream;

            // Scenario 2: Use a publicly accessible URL.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4");
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            eraseVideoSubtitlesAdvanceRequest.VideoUrlObject = stream;
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                AlibabaCloud.SDK.Videoenhan20200320.Models.EraseVideoSubtitlesResponse eraseVideoSubtitlesResponse = client.EraseVideoSubtitlesAdvance(eraseVideoSubtitlesAdvanceRequest, runtime);
                // Get the full response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(eraseVideoSubtitlesResponse.Body));
                // Get a specific field from the response.
                Console.WriteLine(AlibabaCloud.TeaUtil.Common.ToJSONString(eraseVideoSubtitlesResponse.Body.Data));
            }
            catch (TeaException error)
            {
                // If necessary, print the error.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // If necessary, print the error.
                Console.WriteLine(error.Message);
            }
        }
    }
}