Audio Overlays
VideoEditor SDK supports adding predefined audio libraries from which an audio clip can be overlayed on top of the video's soundtrack.
Inside the audio tool, the audio clip can be trimmed and balanced with the original soundtrack of the video.
The corresponding tool is implemented in the AudioToolController
class and can be customized using the AudioToolControllerOptions
.
For details on how to modify the options for the tool, take a look at the configuration section section.
Adding audio clips#
Audio clips can be inserted into AssetCatalog.audioClips
, which is an array of AudioClipCategory
objects. AssetCatalog
is then passed to the Configuration
.
An AudioClipCategory
object holds the metadata of an audio clip category, such as its preview image and the title and has an array of AudioClip
objects,
which again hold the metadata for an AudioClip
, such as its audioURL
, thumbnailURL
and the duration
. The AudioClip
class is not optimized to handle remote resources which therefore should be downloaded in advance and then passed as a local resource.
let audioClips = [Bundle.main.url(forResource: "rain", withExtension: "mp3"),Bundle.main.url(forResource: "thunder", withExtension: "mp3"),Bundle.main.url(forResource: "explosion", withExtension: "mp3"),Bundle.main.url(forResource: "clapping", withExtension: "mp3"),Bundle.main.url(forResource: "laughing", withExtension: "mp3")].compactMap { $0.map { AudioClip(identifier: $0.lastPathComponent, audioURL: $0) } }let previewURL = Bundle.main.url(forResource: "effects", withExtension: "png")!let category = AudioClipCategory(title: "Effects", imageURL: previewURL, audioClips: audioClips)let configuration = Configuration { builder inlet assetCatalog = AssetCatalog.defaultItemsassetCatalog.audioClips = [category]builder.assetCatalog = assetCatalog}