All Products
Search
Document Center

Audio processing

Last Updated: Jul 11, 2019

Overview

We have introduced video editing, its overall process, and the two methods of using the media editing service in Overview. Media editing is essentially initiated and implemented by the media editing service. The timeline is the key data processed by the media editing service and also the core object in video editing. The internal parameters of the timeline can be organized in multiple ways to cope with different business scenarios.

Examples

The following examples show how timeline data is organized for audio processing (including muting, audio mixing, audio extraction, and volume adjustment).

Mute an entire video

This action turns off the sound of an entire video. The following example uses the Volume effect to mute a video. The Gain parameter indicates the volume gain. A value of 0 indicates that the video is muted.

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "3f7e62d41a334dec9ac802b0f165bb92",
  7. "Effects": [
  8. {
  9. "Type": "Volume",
  10. "Gain": "0"
  11. }
  12. ]
  13. }
  14. ]
  15. }
  16. ]
  17. }

Mute the specified part of a video

Compared with the parameters for muting an entire video, this action adds the In and Out parameters to the Volume effect. The following example describes how to mute a video from the 8th second to the 60th second and remain the volume of other parts unchanged:

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "3f7e62d41a334dec9ac802b0f165bb92",
  7. "Effects": [
  8. {
  9. "Type": "Volume",
  10. "Gain": "0",
  11. "In": 8,
  12. "Out": "60"
  13. }
  14. ]
  15. }
  16. ]
  17. }
  18. ]
  19. }

Extract audio

Sometimes, you need to extract the audio from a video as a separate audio resource. To do so, create an audio track by passing in the video as an audio track clip, as shown in the following example. In the example, b3f37e05512043f49f697f7425b9188b is the ID of a video with audio.

  1. {
  2. "AudioTracks": [
  3. {
  4. "AudioTrackClips": [
  5. {
  6. "MediaId": "b3f37e05512043f49f697f7425b9188b"
  7. }
  8. ]
  9. }
  10. ]
  11. }

Mute a video and dub it with a full audio resource

This action mutes a video and dubs it with a full audio resource to generate a new video. This is a typical dubbing scenario. For example:

  • All clips related to audio processing are placed in AudioTracks.
  • The TimelineIn parameter is set to 5, indicating that the output video is dubbed with the audio from the 5th second of the video.
  • If the TimelineOut parameter is not set, the output video is dubbed with the full audio by default. If the output video ends but the audio does not, the audio is truncated and the dubbing stops when the output video ends.

Note: You can place audio-only resources or video resources with audio in AudioTrackClips.

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "3f7e62d41a334dec9ac802b0f165bb92",
  7. "Effects": [
  8. {
  9. "Type": "Volume",
  10. "Gain": "0"
  11. }
  12. ]
  13. }
  14. ]
  15. }
  16. ],
  17. "AudioTracks": [
  18. {
  19. "AudioTrackClips": [
  20. {
  21. "MediaId": "4a71744998414cbe8ea1976435a7817a",
  22. "TimelineIn":5
  23. }
  24. ]
  25. }
  26. ]
  27. }

Mute a video and dub it with the specified part of an audio resource

After muting a video, you can dub the video with the specified part of an audio resource by setting the In and Out parameters for the audio resource.For example, you can extract the part from the 10th second to the 20th second (a 10-second audio track clip) from an audio resource. Then, you can dub a video with the audio track clip from the 5th second of the video.

Note: You can place audio-only resources or video resources with audio in AudioTrackClips.

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "3f7e62d41a334dec9ac802b0f165bb92",
  7. "Effects": [
  8. {
  9. "Type": "Volume",
  10. "Gain": "0"
  11. }
  12. ]
  13. }
  14. ]
  15. }
  16. ],
  17. "AudioTracks": [
  18. {
  19. "AudioTrackClips": [
  20. {
  21. "MediaId": "4a71744998414cbe8ea1976435a7817a",
  22. "In":10,
  23. "Out":20,
  24. "TimelineIn":5
  25. }
  26. ]
  27. }
  28. ]
  29. }

Adjust the volume of a video and dub the video with an audio resource whose volume is also adjusted

You can use the Volume effect to set the volume. In the Volume effect, the Gain parameter indicates the volume gain.

Valid values of the Gain parameter are as follows:

  • 0: The video or audio is muted.
  • 1: The original volume is used.
  • A value between 0 and 1: The volume is lower than the original volume. The smaller the value, the lower the volume.
  • A value greater than 1: The volume is higher than the original volume. The larger the value, the higher the volume.

Note: You can place audio-only resources or video resources with audio in AudioTrackClips.

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "3f7e62d41a334dec9ac802b0f165bb92",
  7. "Effects": [
  8. {
  9. "Type": "Volume",
  10. "Gain": "0.5"
  11. }
  12. ]
  13. }
  14. ]
  15. }
  16. ],
  17. "AudioTracks": [
  18. {
  19. "AudioTrackClips": [
  20. {
  21. "MediaId": "4a71744998414cbe8ea1976435a7817a",
  22. "In":10,
  23. "Out":20,
  24. "TimelineIn":5,
  25. "Effects": [
  26. {
  27. "Type": "Volume",
  28. "Gain": "2"
  29. }
  30. ]
  31. }
  32. ]
  33. }
  34. ]
  35. }

Merge audio

All the preceding examples involve video tracks. Online editing also allows you to process audio-only tracks. The following example describes how to extract specified parts from two audio resources in the same audio track and merge the extracted parts in sequence to generate a 30-second audio resource:

Note: You can place audio-only resources or video resources with audio in AudioTrackClips.

  1. {
  2. "AudioTracks": [
  3. {
  4. "AudioTrackClips": [
  5. {
  6. "MediaId": "b3f37e05512043f49f697f7425b9188b",
  7. "In": 100,
  8. "Out": 120
  9. },
  10. {
  11. "MediaId": "ab654a04ce554e4f806b5f9e5a342fa8",
  12. "In": 50,
  13. "Out": 60
  14. }
  15. ]
  16. }
  17. ]
  18. }

Mix multiple audio tracks

In addition to merging audio in the same audio track, online editing allows you to mix multiple audio tracks. The following example describes how to mix two audio tracks to generate a 20-second audio track:

Note: You can place audio-only resources or video resources with audio in AudioTrackClips.

  1. {
  2. "AudioTracks": [
  3. {
  4. "AudioTrackClips": [
  5. {
  6. "MediaId": "b3f37e05512043f49f697f7425b9188b",
  7. "In": 100,
  8. "Out": 120,
  9. "Effects": [
  10. {
  11. "Type": "Volume",
  12. "Gain": "2"
  13. }
  14. ]
  15. }
  16. ]
  17. },
  18. {
  19. "AudioTrackClips": [
  20. {
  21. "MediaId": "ab654a04ce554e4f806b5f9e5a342fa8",
  22. "In": 50,
  23. "Out": 60,
  24. "Effects": [
  25. {
  26. "Type": "Volume",
  27. "Gain": "1"
  28. }
  29. ]
  30. }
  31. ]
  32. }
  33. ]
  34. }

Perform complex audio processing

This action allows you to dub a video with multiple audio tracks that are mixed, as shown in the following example. In this example, you mute a specified part of a video, adjust the volume of another specified part of the video, and dub the video with multiple audio tracks that are mixed.The procedure is as follows:

  1. Mute video 3f7e62d41a334dec9ac802b0f165bb92 from the 50th second to the 75th second. Extract the clip from the 100th second to the 120th second from audio b3f37e05512043f49f697f7425b9188b. Double the volume of the clip, and add the clip to the video starting from the 50th second to the 70th second. Extract the clip from the 150th second to the 160th second from audio ab654a04ce554e4f806b5f9e5a342fa8. Then, add the clip to the video starting from the 65th second to the 75th second.
  2. The volume remains unchanged in video 3f7e62d41a334dec9ac802b0f165bb92 except for the parts from the 50th second to the 75th second and from the 120th second to the 125th second.

Note: You can place audio-only resources or video resources with audio in AudioTrackClips.

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "3f7e62d41a334dec9ac802b0f165bb92",
  7. "Effects": [
  8. {
  9. "Type": "Volume",
  10. "Gain": "0",
  11. "In": 50,
  12. "Out": "75"
  13. },
  14. {
  15. "Type": "Volume",
  16. "Gain": "0.8",
  17. "In": 120,
  18. "Out": "125"
  19. },
  20. ]
  21. }
  22. ]
  23. }
  24. ],
  25. "AudioTracks": [
  26. {
  27. "AudioTrackClips": [
  28. {
  29. "MediaId": "b3f37e05512043f49f697f7425b9188b",
  30. "In": 100,
  31. "Out": 120,
  32. "TimelineIn":50
  33. "Effects": [
  34. {
  35. "Type": "Volume",
  36. "Gain": "2"
  37. }
  38. ]
  39. }
  40. ]
  41. },
  42. {
  43. "AudioTrackClips": [
  44. {
  45. "MediaId": "ab654a04ce554e4f806b5f9e5a342fa8",
  46. "In": 150,
  47. "Out": 160,
  48. "TimelineIn":65
  49. "Effects": [
  50. {
  51. "Type": "Volume",
  52. "Gain": "1"
  53. }
  54. ]
  55. }
  56. ]
  57. }
  58. ]
  59. }