Skip to content

Instantly share code, notes, and snippets.

View ulaganathan-PalaniVelayutham's full-sized avatar

Mission_lennie ulaganathan-PalaniVelayutham

View GitHub Profile
let videoSize: CGSize
if videoInfo.isPortrait {
videoSize = CGSize(
width: assetVideoTrack.naturalSize.height,
height: assetVideoTrack.naturalSize.width)
}
else {
videoSize = assetVideoTrack.naturalSize
}
//MARK:- Video Layer
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
}
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)
}
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