All Products
Search
Document Center

Intelligent Media Services:Video translation parameters and examples

Last Updated:Dec 13, 2024

This topic describes the parameters of the SubmitVideoTranslationJob operation and provides examples.

Parameters

Parameter

Type

Required

Name

Description

InputConfig

String

Yes

Input configurations

  • JSON string

  • See the following tables for details

OutputConfig

String

Yes

Output configurations

  • JSON string

  • See the following tables for details

EditingConfig

String

Yes

Translation configurations

  • JSON string

  • See the following tables for details

Title

String

No

Title

Description

String

No

Description

UserData

String

No

Custom information

InputConfig

Parameter

Type

Required

Name

Description

Type

String

Yes

Input type

  • Valid values:

    • Video: video

    • Audio: audio

    • Subtitle: subtitle

Video

String

No

The ID or URL of the video file

  • This parameter is required when the Type parameter is set to Video.

  • Valid values:

    • The ID of the media asset.

    • The OSS URL of the media asset in the current Alibaba Cloud account.

    • Other URLs that can be accessed over the Internet.

Audio

String

No

The ID or URL of the audio file

  • This parameter is required when the Type parameter is set to Audio.

  • Valid values:

    • The ID of the media asset.

    • The OSS URL of the media asset in the current Alibaba Cloud account.

    • Other URLs that can be accessed over the Internet.

Subtitle

String

No

The ID or URL of the subtitle file

  • This parameter is required when the Type parameter is set to Subtitle.

  • Valid values:

    • The ID of the media asset.

    • The OSS URL of the media asset in the current Alibaba Cloud account.

    • Other URLs that can be accessed over the Internet.

OutputConfig

Parameter

Type

Required

Name

Description

MediaURL

String

Yes

Output URL

  • An OSS URL in the current Alibaba Cloud account.

  • You must include an extension in the URL path. The output type is determined based on the extension. Supported extension:

    • mp4

EditingConfig

Parameter

Type

Required

Name

Description

SourceLanguage

String

Yes

Source language

  • Valid values:

    • zh: Chinese.

TargetLanguage

String

Yes

Target language

  • Valid values:

    • en: English.

DetextArea

String

No

Subtitle erasure configurations

  • If this parameter is not specified, subtitles are not erased.

  • Valid values:

    • Auto: automatically identifies the area where subtitles are erased.

    • [[x, y, width, height]]: the area where the subtitles are erased. The value is a two-layer array. You can specify multiple areas. The value contains the following options:

      • x: the ratio of the horizontal distance from the upper-left corner of the subtitle frame to the upper-left corner of the video. Valid values: [0,1].

      • y: the ratio of the vertical distance from the upper-left corner of the subtitle frame to the upper-left corner of the video. Valid values: [0,1].

      • width: the ratio of the width of the subtitle frame to the width of the video. Valid values: [0,1].

      • height: the ratio of the height of the subtitle frame to the height of the video. Valid values: [0,1].

SupportEditing

Boolean

No

Secondary editing configurations

  • Valid values:

    • true: supports secondary editing.

    • false: does not support secondary editing.

  • Default value: false.

SubtitleTranslate

String

No

Subtitle translation configurations

  • Subtitle translation configurations

  • If you specify this parameter, subtitle translation is enabled. Otherwise, subtitle translation is disabled.

  • The string conforms to the JSON format. For more information, see the SubtitleTranslate table.

NeedSpeechTranslate

Boolean

No

Speech translation configurations

  • Valid values:

    • true: enables speech translation.

    • false: disables speech translation.

  • Default value: false.

SpeechTranslate

String

No

Speech translation configurations

  • Speech translation configurations

  • If you set NeedSpeechTranslate to true or if this parameter is specified, speech translation is enabled. Otherwise, speech translation is disabled.

  • The string conforms to the JSON format. For more information, see the SpeechTranslate table.

SubtitleTranslate

Name

Type

Required

Name

Description

OcrArea

String

No

OCR area

  • If this parameter is not specified, the subtitle area is automatically identified.

  • Valid values:

  • Auto: automatically identifies the subtitle area

  • [x, y, width, height]: specifies the subtitle area in a single-layer array. You can specify only one area.

    • x: the ratio of the horizontal distance from the upper-left corner of the subtitle frame to the upper-left corner of the video. Valid values: [0,1].

    • y: the ratio of the vertical distance from the upper-left corner of the subtitle frame to the upper-left corner of the video. Valid values: [0,1].

    • width: the ratio of the width of the subtitle frame to the width of the video. Valid values: [0,1].

    • height: the ratio of the height of the subtitle frame to the height of the video. Valid values: [0,1].

SubtitleConfig

String

No

Subtitle synthesis configurations

  • The subtitle effect configurations. The parameters are the same as the subtitle parameters in the SubtitleTrackClip parameter of the timeline. For more information, see Timeline configurations.

SpeechTranslate

Name

Type

Required

Name

Description

SubtitleConfig

String

No

Subtitle synthesis Configurations

  • The subtitle effect configurations. The parameters are the same as the subtitle parameters in the SubtitleTrackClip parameter of the timeline. For more information, see Timeline configurations.

OriginalJobId

String

No

The ID of the original job.

  • If you are not satisfied with the translation results, you can specify the modified subtitle file in InputConfig.Subtitle, and specify the original task ID in this field to regenerate the translated speech.

  • If you set SupportEditing to true to support secondary editing, the job result contains the SpeechTranslationJobId parameter. When you submit the modified subtitle file, specify the value of SpeechTranslationJobId in OriginalJobId.

  • If you set SupportEditing to true to support secondary editing, the job result contains URL of the translated subtitle file in the SpeechTranslatedSubtitleURL parameter. Modify the content of this file and specify the subtitle file in the InputConfig.Subtitle parameter for secondary editing.

Scenario

Modify the subtitle file for speech translation

Background information

If you are not satisfied with the result of the speech translation, you can manually modify the subtitle file and submit the modified subtitle file.

Process

Submit the speech translation job. If manual correction is required, you need to set SupportEditing to true. The following example shows the parameters.

{
    "InputConfig": {
        "Type": "Video",
        "Video": "*****a0052ff71efbfd4e7e6c66*****"
    },
    "OutputConfig": {
        "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/video.mp4"
    },
    "EditingConfig": {
        "SourceLanguage": "zh",
        "TargetLanguage": "en",
        "SupportEditing": true,
        "NeedSpeechTranslate": true
    }
}

The following result is returned:

{
    "MediaId": "*****d306b6d71efbf98f6f7f55*****",
    "TranslatedAudioMediaId": "*****d306b6d71efbf98f6f7f5*****",
    "SpeechTranslatedSubtitleURL": "http://your-bucket.oss-cn-shanghai.aliyuncs.com/video_subtitle_asr_en.srt",
    "SpeechTranslationJobId": "*****74f329d4c03b63e7f7dac8*****"
}

Parameter description:

  1. MediaId: the ID of the output media asset.

  2. TranslatedAudioMediaId: the ID of the translated audio file.

  3. SpeechTranslatedSubtitleURL: the URL of the translated subtitle file.

  4. SpeechTranslationJobId: the ID of the speech translation job. The OriginalJobId parameter must be specified for manual correction.

If you are not satisfied with the translation result, download the subtitle file from SpeechTranslatedSubtitleURL, modify the content of the subtitle file, and submit the speech translation job again. The speech translation job regenerates audio based on the modified subtitle file.

Important

Modify only the text content information in the subtitle file, and do not modify the timeline of the subtitles or increase the number of lines.

The following example shows the parameters for the second job, which includes the original video, the corrected subtitle file, and the ID of the original speech translation job:

{
    "InputConfig": {
        "Type": "Video",
        "Video": "*****a0052ff71efbfd4e7e6c66*****",
        "Subtitle": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/new_subtitle.srt"
    },
    "OutputConfig": {
        "MediaURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/video.mp4"
    },
    "EditingConfig": {
        "SourceLanguage": "zh",
        "TargetLanguage": "en",
        "SupportEditing": true,
        "NeedSpeechTranslate": true,
        "SpeechTranslate": {
            "OriginalJobId": "*****b5d5d604916bb898b3066*****"
        }
    }
}