Viral videos for e-commerce

Updated at:

1. E-commerce video replication API

E-commerce Video Replication is a suite of AI video services for product content creation. It includes video understanding, element replacement, quality checks, and result delivery. The product focuses on consistency between products and people, detail preservation, conversion-focused messaging, and production at scale. It enables targeted replacement of products or people using a hit video template. By preserving the original actions, camera pacing, and marketing structure, you can quickly generate multiple content versions and reduce shooting, editing, and adaptation costs.

Use cases

Video asset scaling: Use an existing e-commerce video as a template to replace specific products or characters. This preserves the original video's camera work, pacing, and marketing message, making it ideal for creating content variations for multiple SKUs, models, regions, and versions.

Rapid asset generation for new product launches: Reduce the need for live-action shooting, studios, and post-production when launching new products in batches. Quickly generate video assets for new items to shorten their time to market. This accelerates the process from analyzing a viral video and its script to launching new, adapted content.

Content testing and iteration: Quickly generate multiple video versions with different selling points, target audiences, scripts, shots, and visual styles. This lets merchants conduct content testing and iterate on their ad creatives.

Product capabilities

Core capabilities

  • Supports two replacement modes:

    • Product replacement (product_replacement): Replaces the product in the source video with a target product. This mode preserves the original presenter, actions, scene, and marketing structure.

    • Person replacement (person_replacement): Replaces the person in the video with a target person from a reference image or description. This mode preserves the source video's product, actions, scene, and marketing structure.

  • Supports two generation modes:

    • Reference generation (reference): Creates a 1:1 replication. It uses the source video as a template to automatically generate a new video of the same duration (the source video must be under 60 seconds). This mode preserves the script, storyboard, actions, scene, and pacing of the source video, only replacing specified content, such as the person or a similar product.

    • Rebuild generation (rebuild): Deconstructs the script, storyboard, and key elements of the source video, preserving only specified core content like the person or product. It then generates a completely new video. This mode is not limited by the source video's duration (the reference video must be 2 to 360 seconds long) and allows you to specify a target duration for the generated video (under 60 seconds).

  • Automated end-to-end, zero-prompt generation: You only need to provide a reference video and an image of the target product or person. The system automatically completes the entire process, from video understanding and script planning to storyboard design, first frame generation, and final video synthesis.

  • Product understanding and information structuring: Identifies the product's category, appearance, material, color, structure, and key components. It then combines this information with the merchant-provided title, attributes, and selling points to generate content for the resulting video.

  • Template video element replacement: Supports the replacement of products or persons within a defined scope. You can also define replacement and protection zones to minimize changes in non-target areas.

  • Product consistency: Ensures the product's form, color, texture, pattern, packaging, and logo remain consistent across different shots, angles, actions, and scenes.

  • Product fidelity: Multiple rounds of VL quality inspection preserve the product's attributes (such as color, texture, structure, and prints) throughout the entire process to prevent feature drift.

  • Selling point script and storyboard replication: Replicates the script and storyboard by analyzing the source video's selling point plan, video structure, shot sequence, demonstration actions, voice-over, and conclusion.

  • Commercial model adaptation: Matches the model's appearance and presentation style to the product's style, fit, target audience, and market demand.

  • Quality check and result feedback: Performs multi-dimensional checks on the main product, person, clothing, text, frame integrity, audio, and overall usability. It also outputs results for manual review.

  • Subtitle burning (optional): When enabled, this feature automatically generates subtitles and delivers three assets: the base video, the video with burned-in subtitles, and an SRT subtitle file. The subtitle text is transcribed from the video's dialogue and synchronized with the audio. It supports Chinese, English, and mixed Chinese-English text. Both video versions are generated from the same base video and are identical in audio track, duration, aspect ratio, resolution, and frame timing, except for the added subtitles. A default style is used for the subtitles, and custom styles are not currently supported. The system automatically attempts to remove any existing subtitles, marketing titles, or text stickers from the source video, regardless of whether subtitle burning is enabled. If the removal process fails or its status is unconfirmed, subtitle burning is skipped to avoid overlapping text. This feature is provided at no extra cost.


API usage overview

How the APIs work

This is an asynchronous process that requires two separate API calls: one to submit a task and another to retrieve the result. The submission API does not return the final video immediately. Instead, it returns a task ID. Use this ID to poll for the final video.

API (Action)

Function

Returns

EcomVideoRecreation

Submits a video replication task.

A TaskId (task ID) immediately.

QueryAsyncTaskResult

Uses the task ID to check the progress and result.

The task status in Data.Status. When the task is complete, the response provides the final video URL in VideoUrl, along with its duration and resolution.

Five-step integration

Step

What to do

API

Result

Common pitfalls

1

Prepare your master video and product/person images. All assets must be provided as publicly accessible URLs.

—

A set of URLs.

The link requires a login, has expired, or is accessible only from an internal network.

2

Submit the task, specifying what to replace, the desired output specifications, and whether you need subtitles.

EcomVideoRecreation

TaskId

A required parameter is missing, causing the API to return an INVALID_PARAMETER error.

3

Poll for progress every 5 seconds or more. We recommend an interval of 20 seconds.

QueryAsyncTaskResult

Data.Status

Checking only the outer Success field and mistakenly assuming the task has succeeded.

4

When the status changes to COMPLETED, parse the Data.Result field. If you enabled subtitles, you will receive two additional URLs.

QueryAsyncTaskResult

VideoUrl, Duration, and Resolution. If subtitles are enabled, you also get VideoUrlWithSubtitles and SubtitleUrl.

Forgetting that the Result field is a JSON string that requires an additional parsing step.

5

Immediately download or transfer the final video.

—

A local video file.

The URL is temporary and becomes inaccessible after a few hours.

Key rules for API calls

  1. Asset URLs must be public and remain accessible throughout the generation process. We recommend a validity period of at least 24 hours.

  2. To determine if the video was generated successfully, check only the Data.Status field. An outer Success: true response only means that the query itself was successful, not that the task has completed. For example, a response with Success: true and Status: FAILED at the same time indicates that the query succeeded, but the task failed.

  3. The URL for the final video is temporary. Download or transfer the video to your storage immediately upon receiving the URL. Do not just store the link.

  4. Subtitles are disabled by default. To enable them, set Output.Subtitles.Enabled to true in your request. When enabled, the response will include URLs for both the subtitled video and the SRT file.

Prerequisites

Item

Description

Endpoint

For services in the Chinese mainland: aidge.cn-beijing.aliyuncs.com (China (Beijing))

Access Key (AK / SK)

Use the Access Key ID and Secret of a RAM user. Do not use your root account's Access Key. The RAM authorization code is aidge, and the required Action is aidge:EcomVideoRecreation. If you receive a NoPermission error, check if a policy such as AliyunAidgeFullAccess is attached to the RAM user.

Region

cn-beijing

API version

2026-04-28

Protocol and format

HTTPS, POST. Requests and responses are in JSON format.

Video generation time

Video replication is an asynchronous task. Processing typically takes 10 to 25 minutes, including queuing time. Complex scenes may take longer. If your task is still in progress after 1 hour, please contact technical support with your task ID and submission time. Do not resubmit a task while it is processing.

V. Action: EcomVideoRecreation (Submit a task)

Submits a video recreation task and asynchronously returns a task ID.

Request parameters

The top-level parameters are in the request body, serialized as JSON, and contain two objects: Input (the input assets) and Output (the desired output video).

Name

Type

Required

Description

Example

Input

object

Yes

Input parameters for video recreation.

—

Output

object

No

Output video specifications and subtitles configuration.

—

Input: Source assets and modes

At this layer, you only need to make one initial choice: whether to change the product or the person (Mode), and whether to use 1:1 replication or deconstruction and remake (RecreateMode). The remaining fields are supporting assets for these two choices.

Name

Type

Required

Description

Example

Mode

string

No

Replacement mode. Valid values: product_replacement (default) or person_replacement

product_replacement

RecreateMode

string

No

Recreation mode. The default value is reference. The valid values are reference (directly references the source video) or rebuild (deconstructs the source video and then regenerates it).

reference

SourceVideoUrl

string

Yes

The HTTP or HTTPS URL of the source video. In reference mode, the video must be 60 seconds or shorter. In rebuild mode, the video must be between 2 and 360 seconds long. The URL must be accessible throughout the task. We recommend setting an expiration of at least 24 hours.

https://example.com/source.mp4

ProductImageUrls

array[string]

No

Required when Mode is product_replacement. An array of URLs for the target product images. You can upload 1 to 8 images for the same SKU. If you provide more than 8 images, only the first 8 are used. For best results, use images with a clear, unobstructed subject and a clean background.

["https://example.com/product.png"]

ProductInfo

object

No

Information about the target product. We recommend providing this information to improve voice-over accuracy.

—

ProductInfo.Title

string

No

Required when Mode is product_replacement. The name of the target product. Maximum length: 200 characters.

Pale Moon Yellow Cooling Sun Shirt

ProductInfo.Category

string

No

The product category.

Women's Clothing / Sun Protection Clothing

ProductInfo.Detail

string

No

Factual product information used to constrain the voice-over content. Examples: SKU, brand, color, material, size, specifications, logo, and usage instructions.

Pale yellow, cooling fabric, back-of-hand sun protection, UPF50+

PersonReferenceImageUrls

array[string]

No

An array of 1 to 5 URLs for the target person's reference images. All images must be of the same person. For best results, we recommend ordering the images as follows: facial close-up, front view, 45-degree view, side view, and back view.

["https://example.com/person.jpg"]

PersonChangeDescription

string

No

The description of or supplementary constraints for the target person, with a length of 1 to 500 characters. This parameter is required if PersonReferenceImageUrls is not provided. If both a reference image and a description are provided, the reference image is used to determine the identity, while the description only supplements features that do not conflict with the reference image.

The target person is an adult male, and the clothing and actions from the source video are retained.

Output: Output video specifications

Name

Type

Required

Description

Values/Example

Quality

string

No

Output resolution. The default is 720p. 480p uses only models that natively support 480p and is not automatically upscaled to 720p if generation fails.

480p, 720p, 1080p

Ratio

string

No

Aspect ratio, default auto (matching the closest aspect ratio supported by the current video model based on the width, height, and rotation information of the source video)

auto, 9:16, 3:4, 1:1, 4:3, 16:9

Duration

integer

No

The target duration in seconds. In reference mode, this value is ignored and forced to -1 to match the source video's duration. In rebuild mode for product replacement, you can specify an integer from 5 to 60; if you pass -1 or omit this parameter, the system determines the duration automatically. In rebuild mode for person replacement, the original duration is preserved, so this parameter must be -1 or omitted.

-1

Subtitles

object

No

The subtitles output configuration. If this object is omitted, subtitles are disabled by default.

{"Enabled": true}

Output.Subtitles: Subtitles configuration

Name

Type

Required

Description

Example

Enabled

boolean

No

Subtitle switch. The default value is false. true means that the service normally returns three files: a video without subtitles, a video with subtitles, and an SRT file. If the subtitling process fails, only the successfully generated artifacts are returned. false or not providing the parameter means that only the video without subtitles is returned.

true

Parameter validation rules

Output.Subtitles is omitted or set to an empty object {} → Subtitles are disabled (Default: false)

Passing Output.Subtitles as null, an array, or other non-object values returns INVALID_PARAMETER.

Output.Subtitles.Enabled set to null, a string, or a number returns INVALID_PARAMETER without automatically defaulting to disabled.

The Output.Subtitles.Style parameter and other style fields are not available in the current version and will be rejected if specified.

Tip: To enable or disable subtitles, you only need to configure the Enabled parameter. Pass true to enable subtitles. Pass false or omit the parameter to disable subtitles.
Note: The Output.Quality input parameter is in lowercase (such as 480p, 720p, and 1080p), while the returned UsageMap.Resolution is in uppercase (such as 480P, 720P, and 1080P).
Aspect ratio guide: 9:16 is the portrait format for mobile devices (the mainstream format for short video apps), 1:1 is the square format, and 16:9 is the landscape format. If you are unsure, enter auto to use the aspect ratio of the source video.

Mode validation

Mode

Description

Submission validation

product_replacement

Product replacement

A valid SourceVideoUrl is required. ProductImageUrls must contain 1 to 8 images for the same SKU. In reference mode, Duration is ignored and forced to -1 to match the source video's duration. In rebuild mode, Duration can be omitted, set to -1, or set to an integer between 5 and 60.

person_replacement

Person replacement

A valid SourceVideoUrl is required. Reference images are optional. If provided, you must supply 1 to 5 images of the same target person. If omitted, PersonChangeDescription is required to generate a person from the description. In reference mode, Duration is ignored and forced to -1. In rebuild mode, Duration must be omitted or set to -1 to preserve the original duration.

All URLs must be accessible throughout the task. We recommend setting an expiration of at least 24 hours. For best results, use product and person reference images that show a clear, unobstructed subject against a clean background.

Examples

Example 1: Product replacement request

This example shows a product replacement task. The presenter, actions, scene, and voice-over structure from the source video are all preserved. Only the displayed product is replaced with the specified sun protection shirt.

{
  "Input": {
    "Mode": "product_replacement",
    "RecreateMode": "reference",
    "SourceVideoUrl": "https://cdn.kehui.design/test/case5_1786428248431.mp4",
    "ProductImageUrls": [
      "https://cdn.kehui.design/test/case5_1786428248431.png"
    ],
    "ProductInfo": {
      "Title": "Pale Yellow Cooling Sun Protection Shirt",
      "Category": "Apparel/Sun Protection Clothing",
      "Detail": "Pale yellow, cooling fabric, sun protection extends to the back of the hand, UPF 50+"
    }
  },
  "Output": {
    "Quality": "720p",
    "Ratio": "9:16",
    "Duration": -1,
    "Subtitles": {
      "Enabled": true
    }
  }
}

Adding "Subtitles": {"Enabled": true} will also return videos with subtitles and SRT files. If you do not need subtitles, delete this line or change it to false.

In reference mode, Output.Duration is ignored, and the system forces its value to -1 to match the source video's duration. The Duration parameter is only used in rebuild mode for product replacement, where you can specify an integer from 5 to 60. If you pass -1 or omit this parameter, the system determines the duration automatically. For person replacement in rebuild mode, the original duration is always preserved.

Example 2: Person replacement request (with reference images)

This example demonstrates a person replacement task using a reference image. The product and overall video content remain the same, but the on-screen person is replaced with the model from the supplied image.

{
  "Input": {
    "Mode": "person_replacement",
    "RecreateMode": "reference",
    "SourceVideoUrl": "https://cdn.kehui.design/test/case5_1786428248431.mp4",
    "PersonReferenceImageUrls": [
      "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260408/sjuytr/wan-r2v-object-girl.jpg"
    ],
    "PersonChangeDescription": "The person's identity is based on the reference image. Other unspecified features are inherited from the source video."
  },
  "Output": {
    "Quality": "1080p",
    "Ratio": "9:16",
    "Subtitles": {
      "Enabled": true
    }
  }
}
Example 3: Person replacement request (without reference images)

Example 3: Person replacement (without a reference image)—Instead of providing a photo, use a text description to specify the target person. If you do not provide a character reference image, simply delete PersonReferenceImageUrls and enter the description of the target person in PersonChangeDescription:

{
  "Input": {
    "Mode": "person_replacement",
    "RecreateMode": "reference",
    "SourceVideoUrl": "https://cdn.kehui.design/test/case5_1786428248431.mp4",
    "PersonChangeDescription": "The target person is a tall, well-proportioned adult male. The original clothing, actions, and scene should be preserved."
  },
  "Output": {
    "Quality": "720p",
    "Ratio": "9:16",
    "Subtitles": {
      "Enabled": true
    }
  }
}

In this mode, the system uses only the original video assets and does not create person image assets. The target person is driven by ChangeDescription. This mode can be run, but it does not guarantee that the generated person is consistent with a specific target identity.

Response

Successful response
{
  "RequestId": "70CBEFDF-BB17-1EB3-8A21-569F3124738F",
  "Code": "success",
  "Success": true,
  "Message": "Task submitted",
  "Data": {
    "TaskId": "task_778fa8bd21804828a5d147050e30edac"
  }
}

Receiving a TaskId means the task has been queued, but it does not mean the video is ready. You must save this ID—you will need it for future queries and must provide it when you contact support.

Error response
{
  "RequestId": "70CBEFDF-BB17-1EB3-8A21-569F3124738F",
  "Code": "INVALID_PARAMETER",
  "Success": false,
  "Message": "When Mode is product_replacement, you must provide between 1 and 8 URLs in Input.ProductImageUrls.",
  "Data": null
}

For example, when you pass a string for Output.Subtitles.Enabled:

{
  "RequestId": "request_subtitle_invalid",
  "Code": "INVALID_PARAMETER",
  "Success": false,
  "Message": "Output.Subtitles.Enabled must be a boolean value and cannot be a string, number, or null.",
  "Data": null
}

On failure, the Message provides a message that can be displayed directly. For handling instructions, see Section 7.

Response parameters

Name

Type

Description

Example

RequestId

string

A unique identifier for the API call.

70CBEFDF-BB17-1EB3-8A21-569F312473F

Code

string

Result code. success indicates success. On failure, the corresponding error code is returned.

success

Success

boolean

Indicates whether the submission was successful.

true

Message

string

More information about the result. On failure, this field contains an error description.

Task submitted

Data.TaskId

string

The asynchronous task ID, used for polling the task status.

task_778fa8bd21804828a5d147050e30edac

Response examples

Successful:

{
  "RequestId": "70CBEFDF-BB17-1EB3-8A21-569F3124738F",
  "Code": "success",
  "Success": true,
  "Message": "Task submitted",
  "Data": {
    "TaskId": "task_778fa8bd21804828a5d147050e30edac"
  }
}

Failed:

{
  "RequestId": "70CBEFDF-BB17-1EB3-8A21-569F3124738F",
  "Code": "INVALID_PARAMETER",
  "Success": false,
  "Message": "When Mode is product_replacement, you must provide between 1 and 8 URLs in Input.ProductImageUrls.",
  "Data": null
}

6. Action: QueryAsyncTaskResult (Query task results)

Use the TaskId returned by the EcomVideoRecreation action to query the task's status and result.

Request parameters

Name

Location

Type

Required

Description

Example

TaskId

Query

string

Yes

The ID of the asynchronous task, returned by the EcomVideoRecreation action.

task_778fa8bd21804828a5d147050e30edac

Response parameters

Name

Type

Description

Example

RequestId

string

The request ID.

CE7F2B64-4E5C-4C69-A437-75A4C9E5C079

Code

string

The result code. A value of success indicates that the request succeeded. Otherwise, an error code is returned.

success

Success

boolean

Indicates whether the query request itself was successful.

true

Message

string

The response message.

Success

Data.TaskId

string

The asynchronous task ID.

task_778fa8bd21804828a5d147050e30edac

Data.Status

string

The task status. See the table below for possible values.

COMPLETED

Data.Result

string

A stringified JSON. When the task completes, this string contains the URLs for the generated artifacts, along with Duration, Resolution, and SubtitlesEnabled. This field is an empty string while the task is in progress.

—

Data.UsageMap

object

The usage information for billing purposes. It includes Resolution (string: 480P, 720P, or 1080P) and Duration (number, in seconds).

—

Task status (Data.Status)

Value

Description

IN_PROGRESS

The task is in progress. Continue polling.

COMPLETED

The task completed successfully. Parse the Data.Result field to get the video URL.

FAILED

The task failed. Parse the Data.Result field to get the error information.

Data.Result fields (Status=COMPLETED)

Name

Type

Description

VideoUrl

string

The download URL for the base video (without burned-in subtitles). This may be a signed URL that expires. It is returned on successful publication, regardless of the subtitle setting. If text removal from the source video fails, this video may still contain the original text.

Duration

number

The actual duration of the video, in seconds.

SubtitlesEnabled

boolean

Indicates whether subtitles were enabled in the original request. Defaults to false.

VideoUrlWithSubtitles

string

The URL for the video with burned-in subtitles. This is returned only if subtitles were enabled and the burn-in process was successful.

SubtitleUrl

string

The URL for the SRT subtitle file (UTF-8 encoded). This is returned only if subtitles were enabled and the SRT file was successfully generated.

Resolution

string

The actual pixel resolution of the final video, such as 720x1280. This is different from the Resolution field in UsageMap, which indicates the resolution tier (e.g., 720P).

Interpreting subtitle artifacts

Data.Result fields

Meaning

Recommendation

VideoUrl + VideoUrlWithSubtitles + SubtitleUrl

All subtitle artifacts are available.

All three artifacts are available for download.

VideoUrl + SubtitleUrl, but no VideoUrlWithSubtitles

The burn-in process failed, or it was skipped because text removal from the source video was incomplete (to avoid overlapping text).

The base video and SRT file are usable. You do not need to resubmit the task.

VideoUrl + VideoUrlWithSubtitles, but no SubtitleUrl

The SRT file failed to generate or upload.

Both video versions are usable. You do not need to resubmit the task.

Only VideoUrl (when subtitles were enabled in the request)

The video contains no dialogue (which is normal for music-only videos), or the transcription or alignment process failed.

The base video is usable. This is expected for videos with only background music.

Only VideoUrlWithSubtitles

An error occurred while publishing the base video, but the subtitled version was successfully generated.

Use the subtitled version. Contact support with the TaskId for assistance.

Data.Result fields (Status=FAILED)

Name

Type

Description

ErrorCode

string

The error code.

ErrorMessage

string

The error message.

To check the result, follow these steps:

  1. First, check the Data.Status field. This field shows the status of the video generation task.

  2. Consider Data.Result: when the status is IN_PROGRESS, it is an empty string, which is expected; when it contains content, it is a stringified JSON object that you must parse again to retrieve the fields within.

  3. Finally, retrieve the VideoUrl (on success) or ErrorMessage (on failure). On success, download the video from the URL. On failure, read the message and refer to the instructions in Part 7.

  4. If you enabled subtitles, check for the VideoUrlWithSubtitles and SubtitleUrl fields and refer to the table above to determine the status of each artifact.

Response examples

In progress:

{
  "RequestId": "CE7F2B64-4E5C-4C69-A437-75A4C9E5C079",
  "Code": "success",
  "Success": true,
  "Message": "Success",
  "Data": {
    "TaskId": "task_778fa8bd21804828a5d147050e30edac",
    "Status": "IN_PROGRESS",
    "Result": ""
  }
}

Completed successfully (subtitles disabled):

{
  "RequestId": "CE7F2B64-4E5C-4C69-A437-75A4C9E5C079",
  "Code": "success",
  "Success": true,
  "Message": "Success",
  "Data": {
    "TaskId": "task_778fa8bd21804828a5d147050e30edac",
    "Status": "COMPLETED",
    "Result": "{\"VideoUrl\":\"https://example.com/artifacts/final.mp4?Expires=...\",\"Duration\":29,\"Resolution\":\"720x1280\",\"SubtitlesEnabled\":false}",
    "UsageMap": {
      "Resolution": "720P",
      "Duration": 29
    }
  }
}

Completed successfully (subtitles enabled, all artifacts delivered):

{
  "RequestId": "request_enabled",
  "Code": "success",
  "Success": true,
  "Message": "Success",
  "Data": {
    "TaskId": "task_enabled",
    "Status": "COMPLETED",
    "Result": "{\"VideoUrl\":\"https://example.com/plain.mp4\",\"Duration\":29,\"Resolution\":\"1080x1920\",\"VideoUrlWithSubtitles\":\"https://example.com/with_subtitles.mp4\",\"SubtitleUrl\":\"https://example.com/subtitles.srt\",\"SubtitlesEnabled\":true}",
    "UsageMap": {
      "Resolution": "1080P",
      "Duration": 29
    }
  }
}

Download or transfer the files immediately, as signed URLs expire.

Completed successfully (subtitles enabled, burn-in failed):

{
  "RequestId": "request_partial",
  "Code": "success",
  "Success": true,
  "Message": "Success",
  "Data": {
    "TaskId": "task_partial",
    "Status": "COMPLETED",
    "Result": "{\"VideoUrl\":\"https://example.com/plain.mp4\",\"SubtitleUrl\":\"https://example.com/subtitles.srt\",\"Duration\":29,\"Resolution\":\"720x1280\",\"SubtitlesEnabled\":true}",
    "UsageMap": {
      "Resolution": "720P",
      "Duration": 29
    }
  }
}

The Status is still COMPLETED because a failure in the subtitle process does not affect the main video generation. The base video and SRT file can be downloaded normally.

Task failed:

{
  "RequestId": "CE7F2B64-4E5C-4C69-A437-75A4C9E5C079",
  "Code": "success",
  "Success": true,
  "Message": "Success",
  "Data": {
    "TaskId": "task_778fa8bd21804828a5d147050e30edac",
    "Status": "FAILED",
    "Result": "{\"ErrorCode\":\"GENERATION_FAILED\",\"ErrorMessage\":\"Video generation failed. Please check if the input image is clear and consistent with the product information.\"}",
    "UsageMap": {
      "Resolution": "",
      "Duration": ""
    }
  }
}

In the final example, note that Success is true and Code is success, even though the task itself failed. A successful query request does not mean the video generation was successful. This is a common pitfall when working with asynchronous APIs.


7. Troubleshooting

Error attribution and handling

Errors occur in one of three places. First, identify where the error occurred, then handle it based on its type.

Location

Appearance

When it occurs

Error on submission

The EcomVideoRecreation action returns Success: false. Check the Code and Message fields.

A required parameter is missing, or an asset URL is inaccessible at submission time. The task has not started.

Failure during processing

The query returns Data.Status: FAILED. Check the ErrorCode and ErrorMessage fields in Data.Result.

The assets were successfully submitted, but a step in the generation process failed.

Blocked by gateway

The API returns an HTTP 429, 403, or 400 error, along with a platform-level code like Throttling, NoPermission, or IncompleteSignature.

The concurrency limit is exceeded, RAM authorization is missing, or the signature is incorrect. These errors are not related to asset content. Do not advise the customer to replace assets.

The following table classifies video recreation errors and provides their corresponding customer-facing messages. The placeholders {asset name} and {product/person} are replaced with specific details in the actual response.

No.

Error type

Error message

Suggested action

Triggering conditions

1

Missing required input

{asset name} is missing, so processing cannot start. Please provide {asset name} and submit again.

Replace asset

Use only after confirming that the customer's original request is missing a required asset. If the system drops a parameter, use the fallback logic and do not attribute the issue to the customer.

2

Asset URL is inaccessible

Cannot access {asset name}. The file may not exist or you may not have permission to access it. Please check the file and URL permissions, or re-upload the asset and submit again.

Replace asset

Use only after confirming that the customer's file or link is unavailable. If an internal attachment binding fails, use the fallback logic. If the same internal code does not map to a customer-facing code in the inventory validation branch, do not use this message.

3

Reference image does not match the selected replacement type

The reference image does not contain the person or product information required for this replacement task. Please upload a {product/person} reference image that contains the required information and submit again.

Replace asset

Use only when the reference image can be read but is confirmed to lack the target information. An image containing both a person and a product is not considered a mismatch. If recognition is uncertain, use the fallback logic.

4

Asset content violation

The content failed the security review and cannot be processed. Please adjust the relevant assets or generation requirements and submit again.

Replace asset

This message only states that the security review failed. Do not provide review details, matching tags, or internal stack traces.

5

Video generated but upload failed

The video was generated, but the upload failed. Please keep the task ID and contact support.

Contact support

Use this when automatic re-upload attempts have also failed. Do not advise the customer to regenerate the video. An upload failure must not override an existing business failure.

6

Script generation failed

The script generation step failed. Please keep the task ID and contact support for investigation.

Contact support

This refers to system-generated script content, not customer-provided content. Do not confuse timeline validation failures with insufficient voice timbre.

7

Image generation failed

The image processing step failed. Please retry after a short wait. If the issue persists, please provide the task ID.

Retry

An incomplete check does not mean the type is mismatched; do not advise the customer to replace the image. A validation failure in the model's structured output is not caused by the customer's image.

8

Video generation failed

The video processing step failed. Please retry after a short wait. If the issue persists, please provide the task ID.

Retry

This error occurs if the structured output from the planning model fails validation; it is not related to the source video's quality. Retrying will not help if the target product never appears in the source video.

9

Other generation step failed

Another processing step failed. Please retry after a short wait. If the issue persists, please provide the task ID.

Retry

An error related to response formatting should not be attributed to the customer's asset. ModelAttemptsExhausted is a wrapper code; if a sub-error exists, report its cause instead of using this generic message.

There are three types of suggested actions. Use this guide to self-diagnose:

Replace asset (Errors 1–4): The problem is with the submitted assets. Replace them and resubmit. This does not indicate a system failure. This category accounts for about 90% of failures.

  • Were all required assets provided? Product replacement requires a product image and a product name. Person replacement requires either a reference image or a text description.

  • Try opening the asset URL in a browser's incognito mode. The URL is valid only if the content is directly visible.

  • Does the reference image match the selected mode? Use a product image for product replacement and a person photo for person replacement.

  • Is the source video between 2 and 360 seconds long?

  • Does any asset contain content that might fail the security review, such as third-party portraits, brand logos, or claims that require qualification?

Retry (Errors 7–9): A system step failed. This issue is not caused by your assets. Resubmit the request with the same parameters after a few minutes. If it fails again, contact support with the task ID. There is one exception for Error 8: if the target product does not appear at all in the source video, retrying will not work. You need to use a different template video that contains the product.

Contact support (Errors 5–6): The video was likely generated successfully but failed to upload, or the script generation step is stuck. Do not repeatedly resubmit the task, as this will consume your quota. Provide the following information:

What to provide

Where to find it

Task ID (TaskId)

The Data.TaskId returned by the submission API.

Request ID (RequestId)

The RequestId from any API response.

Error Message (ErrorMessage)

Query API Data.Result field

A screenshot of the error and the submitted file information.

Required materials as per the official troubleshooting guide.

Submission Time

Especially important if the task has been processing for over an hour.

Mode

The values of Mode and RecreateMode.

Asset URLs

The submitted SourceVideoUrl and other asset URLs.

Subtitle-related failures

A subtitle failure does not cause the entire task to fail. If Data.Status is COMPLETED, the main video was generated successfully. If Data.Result is missing VideoUrlWithSubtitles or SubtitleUrl, refer to the "How to determine subtitle outputs" section in Part Six. Use the successfully returned files, and do not resubmit the task.

Common causes vary depending on the missing output:

What's missing

Possible cause

What you should do

Both subtitle outputs are missing (only VideoUrl is present)

The video has no lines or speech (normal for music-only or silent videos). Line extraction or parsing failed. Subtitle synchronization with speech failed (for example, due to unclear speech). The video's language is not supported (currently supports Chinese, English, and mixed Chinese-English).

The absence of lines is normal. For other issues, the system automatically attempts to recover within the same task. If recovery is not possible, it returns the available outputs.

Missing VideoUrlWithSubtitles

Subtitle burn in failed. The removal of original text failed or was unconfirmed, so the system skipped burn in to avoid overlapping text.

The base video and SRT file are usable. If the issue persists, contact support.

Missing SubtitleUrl

SRT file generation failed, or the output upload failed.

Both video versions are usable. If the issue persists, contact support.

You do not need to resubmit the task for subtitle failures. The system automatically tries to recover within the same task. If recovery is not possible, it returns the available outputs.

If subtitle outputs are consistently missing after multiple queries, contact support with the task ID, submission time, and asset URLs.

Error codes

HTTP status code

Error code

Error message

Description

400

INVALID_PARAMETER

Invalid parameter. See Message for details.

Request validation failed. Please correct the request and retry. The request contains an invalid type for Output.Subtitles.Enabled, Output.Subtitles is not an object, or the Output.Subtitles.Style input parameter is not yet available.

404

TASK_NOT_FOUND

TaskId not found.

The provided TaskId is invalid or has expired.

404

RESOURCE_NOT_FOUND

Asset URL is inaccessible.

Check if the asset URL is valid and publicly accessible.

500

INTERNAL_ERROR

Internal service error.

A server-side error occurred. You can retry the request after a short wait.

If a task has been completed but the output video cannot be exported or the result cannot be mapped to a valid output video, the error is not indicated by the top-level Code parameter. Instead, the task is returned as failed: Data.Status=FAILED, Data.Result.ErrorCode=OUTPUT_MAPPING_FAILED. You can retry the task according to categories 7 to 9.


8. SDK Example (Python)

The following code implements the full "Integrate in five steps" workflow from Section 4: Step 2 (submit task), Step 3 (poll), and Step 4 (parse result). You must implement Step 1 (prepare asset URLs) and Step 5 (download and store the output) yourself.

Install dependencies:

pip install "alibabacloud-tea-openapi>=0.4.5,<1.0.0" "darabonba-core>=1.0.0,<2.0.0"
import json, os, time
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_tea_openapi.client import Client as OpenApiClient
from darabonba.runtime import RuntimeOptions

API_VERSION = "2026-04-28"
ENDPOINT    = os.environ.get("AIDGE_POP_ENDPOINT", "aidge.cn-beijing.aliyuncs.com")
REGION_ID   = os.environ.get("AIDGE_POP_REGION_ID", "cn-beijing")
AK          = os.environ["AIDGE_ACCESS_KEY_ID"]
SK          = os.environ["AIDGE_ACCESS_KEY_SECRET"]

def client():
    cfg = open_api_models.Config(
        access_key_id=AK, access_key_secret=SK,
        endpoint=ENDPOINT, region_id=REGION_ID,
    )
    return OpenApiClient(cfg)

def call(c, action, *, body=None, query=None):
    params = open_api_models.Params(
        action=action, version=API_VERSION,
        protocol="HTTPS", pathname="/", method="POST",
        auth_type="AK", style="RPC",
        req_body_type="json", body_type="json",
    )
    resp = c.call_api(
        params,
        open_api_models.OpenApiRequest(query=query or {}, body=body),
        RuntimeOptions(connect_timeout=60_000, read_timeout=60_000),
    )
    raw = resp.get("body", resp) if isinstance(resp, dict) else resp
    if isinstance(raw, (bytes, bytearray)): raw = raw.decode()
    if isinstance(raw, str): raw = json.loads(raw)
    return raw

def main():
    c = client()

    # 1. Submit the task (with subtitles enabled)
    submit = call(c, "EcomVideoRecreation", body={
        "Input": {
            "Mode": "product_replacement",
            "SourceVideoUrl": "https://example.com/source.mp4",
            "ProductImageUrls": ["https://example.com/product.png"],
            "ProductInfo": {"Title": "Sample Product", "Category": "Sample Category"},
        },
        "Output": {
            "Quality": "720p",
            "Ratio": "9:16",
            "Subtitles": {"Enabled": True},  # Enable subtitles
        },
    })
    task_id = submit["Data"]["TaskId"]
    print("TaskId:", task_id)

    # 2. Poll for the result (recommended interval: 20 seconds)
    deadline = time.monotonic() + 7200
    while time.monotonic() < deadline:
        result = call(c, "QueryAsyncTaskResult", query={"TaskId": task_id})
        status = (result.get("Data") or {}).get("Status", "")
        print("Status:", status)
        if status in {"COMPLETED", "FAILED"}:
            data = result.get("Data") or {}
            raw_result = data.get("Result") or "{}"
            parsed = json.loads(raw_result) if isinstance(raw_result, str) else raw_result
            print(json.dumps({"Status": status, "Result": parsed,
                              "UsageMap": data.get("UsageMap")}, ensure_ascii=False, indent=2))
            if status == "COMPLETED":
                # Base video (always returned on success)
                print("Base video:", parsed.get("VideoUrl"))
                # The following two fields are returned only if subtitles are enabled
                print("Burned video:", parsed.get("VideoUrlWithSubtitles"))
                print("SRT:", parsed.get("SubtitleUrl"))
                print("Resolution:", parsed.get("Resolution"))
            return
        time.sleep(20)

    raise TimeoutError(f"The task did not complete after 2 hours of polling. Please contact technical support with the TaskId: {task_id}")

if __name__ == "__main__":
    main()

Notes:

  • The code under # 1. Submit the task corresponds to Section 5, and the code under # 2. Poll for the result corresponds to Section 6.

  • The polling timeout of 7200 seconds (2 hours) is a client-side safeguard. A task does not time out on the server. If the timeout is reached, you can continue to poll or contact technical support with the TaskId. Do not resubmit the same task.

  • The Result field contains a stringified JSON object that requires a second parsing step, as shown by the parsed variable. Do not skip this step. UsageMap is a free-form key-value map. On failure, its Duration field may be an empty string ("") and should not be treated as a number.

  • The example provides only one URL in ProductImageUrls. In a production environment, provide 1 to 8 images for the same SKU, as specified in the parameter table and SDK comments.

  • To disable subtitles, either remove the "Subtitles": {"Enabled": True} line or change the value to False.


9. Notes

  • All asset URLs must remain accessible during task execution. We recommend an expiration period of at least 24 hours.

  • The URLs for VideoUrl, VideoUrlWithSubtitles, and SubtitleUrl may be signed URLs with an expiration period. Download or transfer the artifacts promptly.

  • The system returns each URL only after its corresponding artifact is generated. A missing URL indicates that the artifact is unavailable. Do not attempt to construct or guess the URLs.

  • For best results, use product images with a clear, unobstructed subject and a solid or simple background.

  • If you provide multiple character reference images, ensure they all show the same person. We recommend including a facial close-up and a front-facing photo.

  • The final video always includes audio. For product replacement, the presenter's audio from the source video is preserved. For character replacement, the original audio from the source video is used.

  • Quality check warnings are returned with the result but do not prevent final video generation or trigger an automatic retry.

  • The top-level Success and Code parameters indicate whether the query request was successful. To determine if the task succeeded, check the Data.Status field.

  • A task can have one of three statuses: IN_PROGRESS, COMPLETED, or FAILED. Task cancellation is not supported, and the API does not return a timeout status. If a task remains IN_PROGRESS for an extended period, contact support with the TaskId. Do not resubmit the task.

  • Subtitles are disabled by default. When enabled, the system automatically generates subtitles by transcribing dialogue from the video and synchronizing it with the audio. The transcription supports Chinese, English, and mixed Chinese-English text but does not perform translation or create bilingual subtitles. This feature is available at no extra cost.

  • Regardless of whether subtitles are enabled, the system automatically attempts to remove any existing hard-coded subtitles, marketing titles, or text stickers from the source video, while preserving text on product packaging, brand logos, and other in-scene text. If the text removal process fails or its status is unconfirmed, the system skips burning in new subtitles to avoid overlapping text.

  • Both video versions (with and without subtitles) are generated from the same base video. They are identical in audio track, duration, aspect ratio, resolution, and frame timing, with the only difference being the added subtitles. The subtitles use a default style, and custom styles are not currently supported.

  • VideoUrl refers to the base video but does not guarantee that all text from the source video has been removed. If the text removal process fails, the original text may remain.

  • A subtitle failure does not cause the entire task to fail. If a subtitle artifact is missing, use the other returned artifacts. The system automatically attempts to recover within the same task, so you do not need to resubmit it.

  • The API accepts one task per request.