All Products
Search
Document Center

ApsaraVideo VOD:Audio processing

Last Updated:Jan 29, 2026

This topic provides examples of common Timeline configurations for audio processing scenarios when you edit videos using OpenAPI. These scenarios include muting an entire video, muting a specified segment, extracting audio, muting a video and mixing it with a full audio track, muting a video and mixing it with a specified audio segment, adjusting video and audio volume, concatenating audio, mixing multiple audio tracks, and advanced dubbing.

Related API operations

Timeline examples

Mute All

Muting an entire video removes all sound from the video resource. The following example uses the Volume effect for audio. Gain represents the volume gain. A value of 0 indicates silence.

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "3f7e62d41a334dec9ac802b0f165****",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0"
                        }
                    ]
                }
            ]
        }
    ]
}

Mute a specified segment

This operation is different from muting an entire video because it adds In and Out parameters to the Volume effect. The following example mutes the video from the 8-second mark to the 60-second mark. The volume of the other parts of the video remains unchanged:

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "3f7e62d41a334dec9ac802b0f165****",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0",
                            "In": 8,
                            "Out": "60"
                        }
                    ]
                }
            ]
        }
    ]
}

Extract audio

In some scenarios, you may need to extract the audio from a video as a separate audio resource. To do this, create an AudioTracks object and pass the video resource as an AudioTrackClip. In the following example, b3f37e05512043f49f697f7425b9**** is the ID of a video resource that contains audio.

{
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "b3f37e05512043f49f697f7425b9****"
                }
            ]
        }
    ]
}

Mute a video and mix with a full audio track

This is a typical dubbing scenario in which you mute the original video and then add a new audio track to create a new video. The following is an example:

  • Put all clips related to audio processing into an AudioTrack.

  • Set TimelineIn to 5. This indicates that the audio is overlaid on the output video, starting at the 5-second mark.

  • If TimelineOut is not set, the entire audio segment is mixed by default. If the audio extends beyond the total duration of the video track, it is truncated to match the end of the video track.

Note

An AudioTrackClip can be an audio-only resource or a video resource with audio.

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "3f7e62d41a334dec9ac802b0f165****",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0"
                        }
                    ]
                }
            ]
        }
    ],
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "4a71744998414cbe8ea1976435a7****",
                    "TimelineIn":5
                }
            ]
        }
    ]
}

Mute a video and mix with a specified audio segment

Unlike mixing with a full audio track, this operation adds settings for the In and Out points of the audio clip. The following example clips the audio segment from the 10-second mark to the 20-second mark (a 10-second audio clip) and overlays it onto the output video, starting at the 5-second mark:

Note

An AudioTrackClip can be an audio-only resource or a video resource with audio.

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "3f7e62d41a334dec9ac802b0f165****",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0"
                        }
                    ]
                }
            ]
        }
    ],
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "4a71744998414cbe8ea1976435a7****",
                    "In":10,
                    "Out":20,
                    "TimelineIn":5
                }
            ]
        }
    ]
}

Adjust video and audio volume

You can use the Volume effect to set the volume. The Gain parameter represents the volume level.

The following describes the Gain parameter:

  • 0: Mutes the audio.

  • 1: Keeps the original volume.

  • A value between 0 and 1 decreases the volume. The smaller the value, the lower the volume.

  • A value greater than 1 increases the volume. The larger the value, the higher the volume.

Note

An AudioTrackClip can be an audio-only resource or a video resource with audio.

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "3f7e62d41a334dec9ac802b0f165****",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0.5"
                        }
                    ]
                }
            ]
        }
    ],
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "4a71744998414cbe8ea1976435a7****",
                    "In":10,
                    "Out":20,
                    "TimelineIn":5,
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "2"
                        }
                    ]
                }
            ]
        }
    ]
}

Concatenate audio

The previous examples all include a video track. However, online editing also supports processing audio-only tracks. The following example clips specified segments from two audio resources on the same audio track, connects them in sequence, and creates a 30-second audio resource:

Note

An AudioTrackClip can be an audio-only resource or a video resource with audio.

{
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "b3f37e05512043f49f697f7425b9****",
                    "In": 100,
                    "Out": 120
                },
                {
                    "MediaId": "ab654a04ce554e4f806b5f9e5a34****",
                    "In": 50,
                    "Out": 60
                }
            ]
        }
    ]
}

Mix multiple audio tracks

In addition to concatenating audio on the same track, online editing supports mixing audio resources from multiple audio tracks. The following example mixes audio from multiple tracks to create a 20-second audio resource:

Note

An AudioTrackClip can be an audio-only resource or a video resource with audio.

{
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "b3f37e05512043f49f697f7425b9****",
                    "In": 100,
                    "Out": 120,
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "2"
                        }
                    ]
                }
            ]
        },
        {
            "AudioTrackClips": [
                {
                    "MediaId": "ab654a04ce554e4f806b5f9e5a34****",
                    "In": 50,
                    "Out": 60,
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "1"
                        }
                    ]
                }
            ]
        }
    ]
}

Advanced dubbing

Advanced dubbing involves mixing a video with multiple audio tracks. The following is a comprehensive example of audio processing that includes muting a specified video segment, adjusting the volume of another segment, and mixing in multiple audio tracks. The specific operations are as follows:

  1. Mute the video 3f7e62d41a334dec9ac802b0f165**** from the 50-second mark to the 75-second mark. During this time, enable two audio tracks for mixing. For the first audio track, clip the segment from the 100-second mark to the 120-second mark of the media asset b3f37e05512043f49f697f7425b9****. Insert this clip to start at the 50-second mark and end at the 70-second mark of the timeline, and increase the volume to 2. For the second audio track, clip the segment from the 150-second mark to the 160-second mark of the media asset ab654a04ce554e4f806b5f9e5a34****. Insert this clip to start at the 65-second mark and end at the 75-second mark.

  2. For the video 3f7e62d41a334dec9ac802b0f165****, the volume remains normal for all segments except for the segment from the 50-second mark to the 75-second mark and the segment from the 120-second mark to the 125-second mark.

Note

An AudioTrackClip can be an audio-only resource or a video resource with audio.

The following is an example:

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "3f7e62d41a334dec9ac802b0f165****",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0",
                            "In": 50,
                            "Out": "75"
                        },
                        {
                            "Type": "Volume",
                            "Gain": "0.8",
                            "In": 120,
                            "Out": "125"
                        },

                    ]
                }
            ]
        }
    ],
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId": "b3f37e05512043f49f697f7425b9****",
                    "In": 100,
                    "Out": 120,
                    "TimelineIn":50
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "2"
                        }
                    ]
                }
            ]
        },
        {
            "AudioTrackClips": [
                {
                    "MediaId": "ab654a04ce554e4f806b5f9e5a34****",
                    "In": 150,
                    "Out": 160,
                    "TimelineIn":65
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "1"
                        }
                    ]
                }
            ]
        }
    ]
}

Configure audio fade-in and fade-out

You can add the "Type": "AFade" field to create an audio fade-in and fade-out effect. For example, you can configure a 3-second fade-in and a 4-second fade-out for a media asset on an audio track. The volume increases and decreases linearly.

{
  "AudioTracks": [
    {
      "AudioTrackClips": [
        {
          "MediaId": "f044b3adc7967ba8f5cdf044b059****",
          "Effects": [
            {
              "Type": "AFade",
              "SubType": "In",
              "Duration": 3,
              "Curve": "tri"
            },
            {
              "Type": "AFade",
              "SubType": "Out",
              "Duration": 4,
              "Curve": "tri"
            }
          ]
        }
      ]
    }
  ]
}

Parameter fields

Type

Required

Description

SubType

string

Yes

The subtype of the audio fade effect. Valid values:

  • In: fade in.

  • Out: fade out.

Duration

float

No

The duration of the fade-in or fade-out effect, in seconds. The fade-in effect is applied to the beginning of the media asset segment, and the fade-out effect is applied to the end. The default value is 0, which means no fade effect is applied.

Curve

string

No

The volume curve for the audio fade effect. Valid values:

  • exp (default): The volume changes exponentially.

  • tri: The volume changes linearly.

Configure audio fade-in and fade-out for a video

Similar to configuring fade effects for an audio track, you can also configure fade-in and fade-out effects for the audio in a video. For example, you can configure a 3-second fade-in and a 4-second fade-out for a media asset with audio on a video track. The volume increases and decreases linearly.

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaId": "f044b3adc7967ba8f5cdf044b059****",
          "Effects": [
            {
              "Type": "AFade",
              "SubType": "In",
              "Curve": "tri",
              "Duration": 3
            },
            {
              "Type": "AFade",
              "SubType": "Out",
              "Duration": 4,
              "Curve": "tri"
            }
          ]
        }
      ]
    }
  ]
}