This is pretty frustrating. I\'m trying to get the size of an AVURLasset, but try to avoid naturalSize since Xcode tells me, this is deprecated in iOS5.
This is a fairly simple extension for AVAsset in Swift 4 to get the size of the video, if available:
extension AVAsset {
var screenSize: CGSize? {
if let track = tracks(withMediaType: .video).first {
let size = __CGSizeApplyAffineTransform(track.naturalSize, track.preferredTransform)
return CGSize(width: fabs(size.width), height: fabs(size.height))
}
return nil
}
}