This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let videoSize: CGSize | |
if videoInfo.isPortrait { | |
videoSize = CGSize( | |
width: assetVideoTrack.naturalSize.height, | |
height: assetVideoTrack.naturalSize.width) | |
} | |
else { | |
videoSize = assetVideoTrack.naturalSize | |
} | |
//MARK:- Video Layer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { | |
guard let url = info[.mediaURL] as? URL else { | |
return | |
} | |
self.dismiss(animated: true) { | |
[weak self] in | |
print(url) | |
// you can pass on this url of the video to do other stuff | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let alertController: UIAlertController = UIAlertController(title: "Pick an option", message: nil, preferredStyle: .actionSheet) | |
let cancelActionButton = UIAlertAction(title: "Cancel", style: .cancel) { | |
_ in | |
} | |
alertController.addAction(cancelActionButton) | |
let imageGalleryAction = UIAlertAction(title: "Choose from Gallery", style: .default) | |
{ | |
[weak self] _ in | |
self?.pickVideo(from: UIImagePickerController.SourceType.photoLibrary) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addWaterMark(toVideofrom url: URL, onComplete: @escaping (URL?, UIImage?) -> Void) { | |
let queue = DispatchQueue.global(qos: .background) | |
queue.async { [self] in | |
1// let asset = AVURLAsset(url: url) | |
2//let composition = AVMutableComposition() | |
3// guard | |
let compositionVideoTrack = composition.addMutableTrack( | |
withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid), | |
let assetVideoTrack = asset.tracks(withMediaType: .video).first |