import UIKit
import VideoEditorSDK
class VideoAddFiltersFromAppBundleSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
let customLUTFilter = LUTEffect(identifier: "custom_lut_filter", lutURL: Bundle.main.url(forResource: "custom_lut_invert", withExtension: "png"), displayName: "Invert", horizontalTileCount: 5, verticalTileCount: 5)
let customDuoToneFilter = DuoToneEffect(identifier: "custom_duotone_filter", lightColor: .yellow, darkColor: .blue, displayName: "Custom")
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.effects.append(contentsOf: [customLUTFilter, customDuoToneFilter])
builder.assetCatalog = assetCatalog
let thumbnailURL = Bundle.main.url(forResource: "custom_filter_category", withExtension: "jpg")!
let thumbnailData = try? Data(contentsOf: thumbnailURL)
let thumbnail = UIImage(data: thumbnailData!)
let customFilterGroup = Group(identifier: "custom_filter_category", displayName: "Custom", thumbnail: thumbnail, memberIdentifiers: ["custom_lut_filter"])
builder.configureFilterToolController { options in
options.filterGroups.append(customFilterGroup)
}
}
let videoEditViewController = VideoEditViewController(videoAsset: video, configuration: configuration)
videoEditViewController.delegate = self
videoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(videoEditViewController, animated: true, completion: nil)
}
func videoEditViewControllerShouldStart(_ videoEditViewController: VideoEditViewController, task: VideoEditorTask) -> Bool {
true
}
func videoEditViewControllerDidFinish(_ videoEditViewController: VideoEditViewController, result: VideoEditorResult) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
func videoEditViewControllerDidFail(_ videoEditViewController: VideoEditViewController, error: VideoEditorError) {
print(error.localizedDescription)
presentingViewController?.dismiss(animated: true, completion: nil)
}
func videoEditViewControllerDidCancel(_ videoEditViewController: VideoEditViewController) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
}