You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Video processing
Audio and Video Merge
Copy page
Download PDF
Audio and Video Merge

The audio-video merging operator is based on FFmpeg and performs sequential concatenation, duration adjustment, and final synthesis of the input video and audio materials. The operator supports various input combinations, including one-to-one, one-to-many, many-to-one, and many-to-many. When the total durations of the video and audio are inconsistent, it automatically selects speed adjustment or trims to the shorter duration based on the configuration, and uploads the resulting video and processing mapping file to TOS.

Operator introduction

Operator ID: las_video_audio_merge

Core capabilities

  • Supports sequential concatenation of multiple video and audio segments.
  • Supports preprocessing video and audio separately according to target duration before merging.
  • Supports automatic selection of alignment strategy: prioritizes speed adjustment, and automatically trims when exceeding the threshold.
  • Supports output of the final video file and mapping file, facilitating tracking of the inputs, durations, and alignment strategy for each merge.
  • The output directory is automatically isolated by account, request chain, and input hash to prevent results of different tasks from overwriting each other.

Effect demonstration

  • Input video
  • Input audio
    旁白.MP3
    Unknown size
  • Merged video
  • Audio and video merge mapping file
    output_1782101516_mapping.json
    Unknown size

    — Used to record input materials, parsed duration, and final alignment strategy.

Supported regions

  • Beijing: cn-beijing
  • Shanghai: cn-shanghai
  • Guangzhou: cn-guangzhou

Operator performance

Sub-item
Performance impact description

Maximum RPM

600

Maximum concurrency

10

Duration

  • The input video duration, re-encoding, speed adjustment, and cropping strategies may affect processing time.
  • When there are multiple segments and duration adjustment is required, re-encoding is usually triggered, which takes longer than simple concatenation.

Input and output requirements

Input requirements

Subdivision

Detailed requirements

Supported input data modalities

  • Video
  • Audio

Input format: Video

  • Format: .mp4, .mov, .mkv, .avi, .webm, .m4v
  • Other: video_urls and audio_urls must both be provided and cannot be empty.

Input format: Audio

  • Format: .mp3, .wav, .aac, .m4a, .flac, .ogg
  • Other: video_urls and audio_urls must both be provided and cannot be empty.

Input path requirements

Provide input data to the operator via the request parameters video_urls and audio_urls, which are concatenated in array order. Currently, two methods are supported: public URL and TOS path.

  • Public URL: Video URL accessible via the public network, format is http/https.
  • TOS path: Upload the data to be processed to a TOS Bucket under the same primary account and region as the current LAS service, then provide the TOS path in the format tos://bucket_name/demo.

Output requirements

Subdivision

Detailed requirements

Output data modalities

  • Video

Output path: TOS

Specify the storage path for the operator output results via the request parameter output_tos_path. Currently, setting to a TOS path is supported.

  • TOS path: A writable TOS Bucket directory under the same primary account and region as the LAS service.

Billing instructions
  • Billing standards

    Sub-items
    Billing standards description

    Billing item

    Billing is based on usage calculated from the duration of the input video.

    Billing type

    Usage-based billing, unit: CNY/minute, billed hourly based on actual usage.

    Unit price

    0.02 CNY/minute

  • Billing details
    Billing formula: Total cost = unit price * usage

Cautions and prerequisites

Details

Caution and prerequisites

Costs

Before calling an operator, you need to understand the model invocation costs associated with using the operator. For details, see Large model invocation billing.

Authentication (API Key)

Before calling an operator, you need to generate an API Key for operator invocation. It is recommended to configure the API Key as an environment variable to ensure safer operator calls. For details, see Obtain and configure API Key.

BaseURL

Before calling an operator, you need to determine the BaseURL for operator invocation based on the region where your current LAS service is deployed. This is used to configure the path parameter values for operator calls.
For details, see Obtain the Base URL. The Examples below are for reference only; when making actual calls, replace the path values with those corresponding to your region.

Rest API invocation

API usage instructions

  • The API for this operator is an asynchronous task interface. You need to submit a task through the Submit interface to obtain the task's task_id, and then use the Poll interface to get the running status of the corresponding task (task_id) and retrieve the operator processing result.
  • Caution: After a task is submitted, the task_id is valid for 3 days. After 3 days, you will no longer be able to use this task_id to obtain the operator processing result.

Submit

Interface description

Invoke the audio-video merge operator to submit an asynchronous task, supporting concatenation of multiple video and audio segments, duration adjustment, and final synthesis.

Request parameters

const properties = ("columns": [
{ "title": "Parameter", "dataIndex": "column_0", "key": "column_0", "width": 300 },
{ "title": "Type", "dataIndex": "column_1", "key": "column_1", "width": 150 },
{ "title": "Required", "dataIndex": "column_2", "key": "column_2", "width": 80 },
{ "title": "Example value", "dataIndex": "column_3", "key": "column_3", "width": 150 },
{ "title": "Description", "dataIndex": "column_4", "key": "column_4" }
  ],
  "data": [
    {
      "key": "1",
      "column_0": "operator_id",
      "column_1": "string",
"column_2": "Yes",
      "column_3": "las_video_audio_merge",
"column_4": "Operator ID."
    },
    {
      "key": "2",
      "column_0": "operator_version",
      "column_1": "string",
"column_2": "Yes",
      "column_3": "v1",
"column_4": "Operator version."
    },
    {
      "key": "3",
      "column_0": "data",
      "column_1": "VideoAudioMergeUserReqParams",
"column_2": "Yes",
      "column_3": "",
"column_4": "Audio and Video Merge request parameters.",
      "children": [
        {
          "key": "3-1",
          "column_0": "video_urls",
          "column_1": "list of string",
"column_2": "Yes",
          "column_3": "[\"tos://bucket/input/video_01.mp4\", \"tos://bucket/input/video_02.mp4\"]",
"column_4": < div> Video input list, must contain at least 1 item, concatenated in array order. Supports HTTP/HTTPS URLs accessible from the public internet, as well as < code> tos://bucket/key</ code> that are under the same primary account, in the same region as the LAS service, and readable by the current identity. Supports < code>.mp4</ code>, < code>.mov</ code>, < code>.mkv</ code>, < code>.avi</ code>, < code>.webm</ code>, < code>.m4v</ code>. If the TOS path ends with < code>/</ code>, the video files in the directory will be expanded. To precisely control the order and the correspondence with < code> video_durations</ code>, it is recommended to explicitly provide the object paths. </div>
        },
        {
          "key": "3-2",
          "column_0": "audio_urls",
          "column_1": "list of string",
"column_2": "Yes",
          "column_3": "[\"tos://bucket/input/audio_01.mp3\"]",
"column_4": < div> Audio input list, must contain at least 1 item, concatenated in array order. Supports HTTP/HTTPS URLs accessible from the public internet, as well as < code> tos://bucket/key</ code> that are under the same primary account, in the same region as the LAS service, and readable by the current identity. Supports < code>.mp3</ code>, < code>.wav</ code>, < code>.aac</ code>, < code>.m4a</ code>, < code>.flac</ code>, < code>.ogg</ code>. Directory expansion is not supported. </div>
        },
        {
          "key": "3-3",
          "column_0": "output_tos_path",
          "column_1": "string",
"column_2": "Yes",
          "column_3": "tos://bucket/output/merge_results/",
"column_4": < div> Output root directory. Must be a TOS directory under the same primary account, in the same region as the LAS service, and writable by the current identity. It is recommended to end with < code>/</ code>. The service will append isolation subdirectories such as account, request chain, and input hash under this root directory. The final write location is subject to the path returned by Poll. If the path format is invalid or access is denied, < code> Tos.AccessFailed</ code> will be returned. </div>
        },
        {
          "key": "3-4",
          "column_0": "output_basename",
          "column_1": "string",
"column_2": "No",
          "column_3": "merged_result",
"column_4": < div> Output file basename, excluding directory and extension. If not provided, the system will generate it automatically; it is recommended to use only letters, digits, underscores, and hyphens. The final output will be < code>&#123; output_basename&#125;.mp4</ code> and < code>&#123; output_basename&#125;_mapping.json</ code>. If path separators, file extensions, or invalid characters are included, returns < code> Parameter.Invalid</ code>. </div>
        },
        {
          "key": "3-5",
          "column_0": "video_durations",
          "column_1": "list of float",
"column_2": "No",
          "column_3": "[6.0, 6.0]",
"column_4": < div> Target duration for video segments, in seconds. The length provided must match the final number of videos after directory expansion, and correspond to each item in the final input order; each value must be greater than < code> 0</ code>. The service will trim or adjust the speed of segments according to the target duration, and the actual strategy is recorded in the mapping JSON. If the lengths are inconsistent, or elements are not numeric or not positive, returns < code> Parameter.Invalid</ code>. </div>
        },
        {
          "key": "3-6",
          "column_0": "audio_durations",
          "column_1": "list of float",
"column_2": "No",
          "column_3": "[12.0]",
"column_4": < div> Target duration for audio segments, in seconds. The length provided must equal the number of < code> audio_urls</ code>, and correspond to each item in input order; each value must be greater than < code> 0</ code>. The service will trim or adjust the speed of segments according to the target duration, and the actual strategy is recorded in the mapping JSON. If the lengths are inconsistent, or elements are not numeric or not positive, returns < code> Parameter.Invalid</ code>. </div>
        },
        {
          "key": "3-7",
          "column_0": "max_speed_ratio",
          "column_1": "float",
"column_2": "No",
          "column_3": "1.25",
"column_4": < div> Maximum speed adjustment ratio allowed for audio-video alignment, range < code>&#91; 1.0, 3.0&#93;</ code>, default < code> 1.25</ code>. If the required ratio does not exceed this value, adjust the specified side according to < code> speed_control_target</ code>; if it exceeds this value, do not continue with large speed adjustments, but trim the output according to the shorter side's duration. This parameter affects the output duration and processing time. </div>
        },
        {
          "key": "3-8",
          "column_0": "speed_control_target",
          "column_1": "string",
"column_2": "No",
          "column_3": "audio",
"column_4": < div> The object prioritized for speed adjustment during alignment. < code> audio</ code>: Default value, prioritize adjusting audio speed to match the total video duration; < code> video</ code>: Prioritize adjusting video speed to match the total audio duration. If the required ratio exceeds < code> max_speed_ratio</ code>, fallback to trimming according to the shorter side. Other values return < code> Parameter.Invalid</ code>. </div>
        }
      ]
    }
  ]
}); 
return <Table border={{ cell: true, wrapper: true }} pagination={false} {...properties} />;

Response parameters

const properties = (defaultExpandAllRows: true,
  "columns": [
{ "title": "Parameter", "dataIndex": "column_0", "key": "column_0", "width": 300 },
{ "title": "Type", "dataIndex": "column_1", "key": "column_1", "width": 150 },
{ "title": "Example value", "dataIndex": "column_2", "key": "column_2", "width": 150 },
{ "title": "Description", "dataIndex": "column_3", "key": "column_3" }
  ],
  "data": [
    {
      "key": "1",
      "column_0": "metadata",
      "column_1": "metadata",
      "column_2": "",
"column_3": "Request metadata",
      "children": [
        {
          "key": "1-1",
          "column_0": "task_id",
          "column_1": "string",
          "column_2": "task-xxx",
"column_3": "Task ID in asynchronous mode, used for job status queries."
        },
        {
          "key": "1-2",
          "column_0": "task_status",
          "column_1": "string",
          "column_2": "PENDING",
"column_3": <div> Task status in asynchronous mode. <ul><li> PENDING, request received</li><li> RUNNING, running</li><li> COMPLETED, completed</li><li> FAILED, failed</li><li> TIMEOUT, timed out</li></ul> </div>
        },
        {
          "key": "1-3",
          "column_0": "business_code",
          "column_1": "string",
          "column_2": "0",
"column_3": "Business code."
        },
        {
          "key": "1-4",
          "column_0": "error_msg",
          "column_1": "string",
          "column_2": "",
"column_3": "If an exception occurs, detailed error information will be returned."
        }
      ]
    }
  ]
}); 
return <Table border={{ cell: true, wrapper: true }} pagination={false} {...properties} />;

Example

Request example

# Please set OUTPUT_TOS_PATH to a tos path writable by your account
export OUTPUT_TOS_PATH="tos://path/to/merge_results"

curl --location "https://operator.las.ap-southeast-1.volces.com/api/v1/submit" --header "Content-Type: application/json" --header "Authorization: Bearer $LAS_API_KEY" --data '{
    "operator_id": "las_video_audio_merge",
    "operator_version": "v1",
    "data": {
        "video_urls": [
            "https://las-demo.tos-cn-beijing.volces.com/las_video_audio_merge/v1/videos/seg_001_0.000-6.000.mp4",
            "https://las-demo.tos-cn-beijing.volces.com/las_video_audio_merge/v1/videos/seg_002_6.000-12.000.mp4"
        ],
        "audio_urls": [
            "https://las-demo.tos-cn-beijing.volces.com/las_video_audio_merge/v1/audio/audio_001.mp3"
        ],
        "output_tos_path": "'$OUTPUT_TOS_PATH'"
    }
}'

Response example

{
    "metadata": {
        "task_id": "task-20260323153012-abc123",
        "task_status": "PENDING",
        "business_code": "0",
        "error_msg": ""
    }
}

Error codes

HttpStatusCode

Error codes

Error message

Description

400

Parameter.Missing

Missing required parameter

Missing required parameter.

400

Parameter.Invalid

invalid parameter

Parameter type, enumeration, range, or array length is invalid.

400

Url.Invalid

invalid url

The input address format is invalid.

400

Tos.AccessFailed

Failed to access TOS path with provided credentials

TOS path format error, object does not exist, or no read/write permission.

500

InternalError

Internal server error

Internal server error.

When a task enters FAILED or TIMEOUT, the following business errors are returned via Poll. The actual coverage of error codes is subject to the service response.

Business errors during task execution

Error codes

Description

Video.Invalid

Video file is invalid or cannot be decoded.

Video.DownloadFailed

Video download failed.

Video.FormatUnsupported

Video format not supported.

Video.Timeout

Audio and video processing timed out.

Video.UploadFailed

Failed to upload synthesized video.

Video.DurationTooShort

Video duration is too short.

Audio.DownloadFailed

Audio download failed.

Audio.FormatUnsupported

Audio format not supported.

Audio.UploadFailed

Failed to upload audio processing artifacts or mapping files.

Poll

Interface description

Call this interface to query the execution status and result of the asynchronous Audio and Video Merge task.

Request parameters

Parameter

Type

Required

Example value

Description

operator_id

string

is

las_video_audio_merge

Operator ID

operator_version

string

is

v1

Operator version

task_id

string

is

task-xxx

Task ID

Response parameters

const properties = ("columns": [
{ "title": "Parameter", "dataIndex": "column_0", "key": "column_0", "width": 300 },
{ "title": "Type", "dataIndex": "column_1", "key": "column_1", "width": 150 },
{ "title": "Example value", "dataIndex": "column_3", "key": "column_3", "width": 150 },
{ "title": "Description", "dataIndex": "column_4", "key": "column_4" }
  ],
  "data": [
    {
      "key": "1",
      "column_0": "metadata",
      "column_1": "Metadata",
      "column_3": "",
"column_4": "Task metadata.",
      "children": [
        {
          "key": "1-1",
          "column_0": "task_id",
          "column_1": "string",
          "column_3": "task-20260323153012-abc123",
"column_4": "Asynchronous task ID."
        },
        {
          "key": "1-2",
          "column_0": "task_status",
          "column_1": "string",
          "column_3": "COMPLETED",
"column_4": < div> Task status: < code> PENDING</ code> (task received and queued, continue polling), < code> RUNNING</ code> (processing, continue polling), < code> COMPLETED</ code> (successful terminal state, read < code> data</ code>), < code> FAILED</ code> (failed terminal state, check < code> business_code</ code> and < code> error_msg</ code>), < code> TIMEOUT</ code> (timeout terminal state). </div>
        },
        {
          "key": "1-3",
          "column_0": "submit_time",
          "column_1": "string",
          "column_3": "2026-07-21T16:04:06+08:00",
"column_4": "Task submission time, formatted as ISO 8601 timestamp."
        },
        {
          "key": "1-4",
          "column_0": "end_time",
          "column_1": "string",
          "column_3": "2026-07-21T16:04:16+08:00",
"column_4": "Task end time, formatted as ISO 8601 timestamp; may be empty if the task has not ended."
        },
        {
          "key": "1-5",
          "column_0": "business_code",
          "column_1": "string",
          "column_3": "0",
"column_4": < div> Business code. < code> 0</ code> indicates success; any value other than < code> 0</ code> indicates a task execution exception. For details, see < code> error_msg</ code>. </div>
        },
        {
          "key": "1-6",
          "column_0": "error_msg",
          "column_1": "string",
          "column_3": "",
"column_4": "Error message; empty if successful, returns exception details if failed or timed out."
        }
      ]
    },
    {
      "key": "2",
      "column_0": "data",
      "column_1": "VideoAudioMergeResponse",
      "column_3": "",
"column_4": < div> Merged result. Complete data is returned only when < code> task_status=COMPLETED</ code> and < code> business_code=0</ code>; for statuses < code> PENDING</ code>, < code> RUNNING</ code>, < code> FAILED</ code>, < code> TIMEOUT</ code>, no data is returned or the result is empty. </div>,
      "children": [
        {
          "key": "2-1",
          "column_0": "output_video_path",
          "column_1": "string",
          "column_3": "tos://bucket/output/merge_results/.../merged_result.mp4",
"column_4": < div> The actual TOS address of the merged video. The service will append an isolated subdirectory under the root directory specified by < code> output_tos_path</ code> in Submit, so the caller should not assume the file is directly located in the root directory. </div>
        },
        {
          "key": "2-2",
          "column_0": "output_video_url",
          "column_1": "string",
          "column_3": "https://example-presigned-url",
"column_4": < div> Temporary pre-signed access link for the merged video, valid for 24 hours from the time it is generated by the server. After the link expires, < code> output_video_path</ code> can be used to access according to TOS permissions; do not save or publicly share the temporary link for long-term use. </div>
        },
        {
          "key": "2-3",
          "column_0": "mapping_json_path",
          "column_1": "string",
          "column_3": "tos://bucket/output/merge_results/.../merged_result_mapping.json",
"column_4": "The actual TOS address of the mapping JSON file, which records the input materials, parsed duration, and final alignment strategy. The service will append an isolated subdirectory under the output root directory; the caller should use the returned path as the reference."
        }
      ]
    }
  ]
}); 
return <Table border={{ cell: true, wrapper: true }} pagination={false} {...properties} />;

Example

Request example

curl --location "https://operator.las.ap-southeast-1.volces.com/api/v1/poll" --header "Content-Type: application/json" --header "Authorization: Bearer $LAS_API_KEY" --data '{
    "operator_id": "las_video_audio_merge",
    "operator_version": "v1",
    "task_id": "task-20260323153012-abc123"
}'

Response example

{
  "metadata": {
    "task_id": "task-20260323153012-abc123",
    "task_status": "COMPLETED",
    "submit_time": "2026-07-21T16:04:06+08:00",
    "end_time": "2026-07-21T16:04:16+08:00",
    "business_code": "0",
    "error_msg": ""
  },
  "data": {
    "output_video_path": "tos://your-bucket/output/merge_results/.../merged_result.mp4",
    "output_video_url": "https://example-presigned-url",
    "mapping_json_path": "tos://your-bucket/output/merge_results/.../merged_result_mapping.json"
  }
}

Error codes

HttpStatusCode

Error codes

Error message

Description

400

Parameter.Missing

Missing required parameter

Missing required parameter.

400

Parameter.Invalid

invalid parameter

Invalid parameter.

400

Task.NotFound

Task not found

The task does not exist, has expired, or the current identity is not authorized to query.

500

InternalError

Internal server error

Internal server error.

When a task enters FAILED or TIMEOUT, the following error codes are returned via metadata.business_code and metadata.error_msg. The actual coverage of error codes is subject to the service response.

Business errors during task execution

Error codes

Description

Url.Invalid

The input address is inaccessible or the format is invalid.

Video.Invalid

Video file is invalid or cannot be decoded.

Video.DownloadFailed

Video download failed.

Video.FormatUnsupported

Video format not supported.

Video.Timeout

Audio and video processing timed out.

Video.UploadFailed

Failed to upload synthesized video.

Video.DurationTooShort

Video duration is too short.

Audio.DownloadFailed

Audio download failed.

Audio.FormatUnsupported

Audio format not supported.

Audio.UploadFailed

Failed to upload audio processing artifacts or mapping files.

Tos.AccessFailed

TOS input or output path does not exist, is cross-account/region, or the current identity does not have access permission.

Last updated: 2026.08.18 15:00:37