VideoEditor facilitates video editing
- iOS 9.0 or later
- Xcode 11.0 or later
pod 'VideoEditor', '1.1'
At this point your workspace should build without error. If you are having problem, post to the Issue and the community can help you solve it.
import VideoEditor
1: Prepare the source video asset.
let videoAsset = VideoEditor.Asset(localURL: yourVideoLocalURL, volume: 1)
- With
volume
, you can able to adjust to volume of video in 0...1
2: Prepare the audios
let firstAudioAsset = VideoEditor.Asset(localURL: firstAudioLocalURL, volume: 0.5, startTime: .zero, duration: videoDuration)
let secondAudioAsset = VideoEditor.Asset(localURL: secondAudioLocalURL, volume: 0.7, startTime: CMTime(seconds: 2, preferredTimescale: CMTimeScale(NSEC_PER_SEC)), duration: secondAudioDuration)
-
startTime
is the point of time that you wanna add your audio into the final video, e.g. add setstartTime
asCMTime(seconds: 3, preferredTimescale: CMTimeScale(NSEC_PER_SEC))
to tell engine to start add this audio from the third second of the final video. -
duration
indicates how long the audio will be added into the final video from thestartTime
. Usually set it equal to the audio asset duration. Setnil
to tell theduration
is its duration.
3: Start to merge
let videoEditor = VideoEditor()
videoEditor.merge(video: videoAsset, audios: [firstAudioAsset, secondAudioAsset], progress: { progress in
print(progress)
}, completion: { result in
switch result {
case .success(let videoURL):
print(videoURL)
case .failure(let error):
print(error)
}
})
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
All source code is licensed under the MIT License.