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

Lake AI Service

Copy page
Download PDF
Video processing
Audio and video merging
Copy page
Download PDF
Audio and video merging

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

Supported regions

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

Operator performance

Sub-items
Performance impact description

Maximum RPM

600

Maximum concurrency

10

Duration

  • Total duration mainly depends on the input video length.

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 request parameters video_urls and audio_urls. 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 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

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

Parameter
Type
Required
Example value
Description
operator_id
string
Yes
las_video_audio_merge
Operator ID
operator_version
string
Yes
v1
Operator version
data
VideoAudioMergeUserReqParams
Yes
Audio-video merge request parameters
video_urls
array
Yes
["https://example/sample_video_01.mp4", "https://example/sample_video_02.mp4"]
Video input list. Supports http/https, tos://bucket/key. When an element is a TOS directory ending with /, video files in the directory are automatically enumerated.
audio_urls
array
Yes
["https://example/sample_audio.mp3"]
Audio input list. Supports http/https, tos://bucket/key.
output_tos_path
string
Yes
tos://bucket/output/
Output root directory. The operator will automatically append task-related subdirectories under this directory to save results.
output_basename
string
No
merged_result
Output file base name. Final output { output_basename}.mp4 and { output_basename}_mapping.json; generated automatically by default.
video_durations
array
No
[5.0, 5.0]
Target duration (seconds) for each video segment. The list length must match the number of video inputs, and each duration must be greater than 0.
audio_durations
array
No
[5.0, 5.0]
Target duration (seconds) for each audio segment. The list length must match the number of audio inputs, and each duration must be greater than 0.
max_speed_ratio
float
No
1.25
The maximum speed adjustment ratio allowed for audio-video alignment, value range 1.0 ~ 3.0, default 1.25. When the difference in audio and video duration exceeds this range, the operator will fall back to trimming based on the shorter side, rather than continuing to significantly adjust the speed.
speed_control_target
string
No
video
The side that is prioritized for adjustment. Optional values: video, audio; default: audio.

Response parameters

Parameter
Type
Example value
Description
metadata
metadata
Request metadata
task_id
string
task-xxx
Task ID in asynchronous mode, used for job status queries.
task_status
string
PENDING
Task status in asynchronous mode.
  • PENDING, request received
  • RUNNING, running
  • COMPLETED, completed
  • FAILED, failed
  • TIMEOUT, timed out
business_code
string
0
Business code.
error_msg
string
If an exception occurs, detailed error information will be returned.

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

HttpCode

Error codes

Error message

Description

400

Parameter.Missing

Missing required parameter

Missing required parameter.

400

Parameter.Invalid

invalid parameter

Invalid parameter.

400

Url.Invalid

invalid url

Invalid input address.

400

Video.Invalid

invalid video file

Video file is invalid or cannot be decoded.

400

Video.DownloadFailed

Video download failed

Video download failed.

400

Video.FormatUnsupported

Video format not supported

Video format not supported.

400

Video.Timeout

Video processing timeout

FFmpeg processing timed out.

400

Video.UploadFailed

Video upload failed

Failed to upload synthesized video.

400

Video.DurationTooShort

Video duration is too short

Video duration is too short.

400

Audio.DownloadFailed

Audio download failed

Audio download failed.

400

Audio.FormatUnsupported

Audio format not supported

Audio format not supported.

400

Audio.UploadFailed

Audio upload failed

Failed to upload audio or mapping file.

400

Tos.AccessFailed

Failed to access TOS path with provided credentials

Failed to access TOS.

400

Task.NotFound

Task not found

Task does not exist.

500

InternalError

Internal server error

Internal server error.

Poll

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

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

Parameter
Type
Example value
Description
metadata
metadata
Request metadata
task_id
string
task-xxx
Task ID in asynchronous mode.
task_status
string
COMPLETED
Task status in asynchronous mode.
  • PENDING, task submitted and queued
  • RUNNING, in progress
  • COMPLETED, completed
  • FAILED, failed
  • TIMEOUT, timed out
submit_time
string
2026-07-21T16:04:06+08:00
Task submission time, in ISO 8601 timestamp format.
end_time
string
2026-07-21T16:04:06+08:00
Task end time, in ISO 8601 timestamp format.
business_code
string
0
Business code.
error_msg
string
If an exception occurs, detailed error information will be returned.
data
VideoAudioMergeResponse
Returned data
output_video_path
string
tos://bucket/output/123/trace/hash/merged_result.mp4
TOS address of the merged video.
output_video_url
string
https://video.mp4
Pre-signed URL for the merged video, valid for 24 hours.
mapping_json_path
string
tos://bucket/output/123/trace/hash/merged_result_mapping.json
Address of the mapping JSON file, which records the input materials, duration, and final alignment strategy.

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:06+08:00",
        "business_code": "0",
        "error_msg": ""
    },
    "data": {
        "output_video_path": "tos://path/to/merge_results/123456/trace-20260323-abc123/4d8d4a3f0a3c1d2e_1742726400/merged_result.mp4",
        "mapping_json_path": "tos://path/to/merge_results/123456/trace-20260323-abc123/4d8d4a3f0a3c1d2e_1742726400/merged_result_mapping.json"
    }
}
Last updated: 2026.07.28 15:20:03