Q:

AVURLAsset getting video size

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. 
But: What's the replacement?
I can't find any clue on how to get the video-dimensions without using «naturalsize»...

A:

Resolution in Swift 3:
func resolutionSizeForLocalVideo(url:NSURL) -> CGSize? {
    guard let track = AVAsset(URL: url).tracksWithMediaType(AVMediaTypeVideo).first else { return nil }
    let size = CGSizeApplyAffineTransform(track.naturalSize, track.preferredTransform)
    return CGSize(width: fabs(size.width), height: fabs(size.height))
}

For Swift 4:
func resolutionSizeForLocalVideo(url:NSURL) -> CGSize? {
    guard let track = AVAsset(url: url as URL).tracks(withMediaType: AVMediaType.video).first else { return nil }
    let size = track.naturalSize.applying(track.preferredTransform)
    return CGSize(width: fabs(size.width), height: fabs(size.height))
}

Solutions without preferredTransform do not return correct values for some videos on the latest devices!

A:

I just checked the documentation online, and the naturalSize method is deprecated for the AVAsset object. However, there should always be an AVAssetTrack which refers to the AVAsset, and the AVAssetTrack has a naturalSize method that you can call. 

naturalSize 
The natural dimensions of the media data referenced by the track. (read-only)
@property(nonatomic, readonly) CGSize naturalSize 
Availability
Available in iOS 4.0 and later. Declared In AVAssetTrack.h

Via: AVAssetTrack Reference for iOS

A:

The deprecation warning on the official documentation suggests, "Use the naturalSize and preferredTransform, as appropriate, of the asset’s video tracks instead (see also tracksWithMediaType:)."
I changed my code from:
CGSize size = [movieAsset naturalSize];

to
CGSize size = [[[movieAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] naturalSize];

It's less pretty and less safe now but won't break when they drop that method.

