Created
April 30, 2013 14:29
-
-
Save autresphere/5489099 to your computer and use it in GitHub Desktop.
Retrieves the size of a video from its path.
This file contains hidden or 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
+ (CGSize)sizeOfVideoAtPath:(NSString *)path | |
{ | |
NSURL *url; | |
AVAsset *asset; | |
NSArray *tracks; | |
url = [NSURL fileURLWithPath:path]; | |
asset = [[AVURLAsset alloc] initWithURL:url options:nil]; | |
tracks = [asset tracksWithMediaType:AVMediaTypeVideo]; | |
if(tracks != nil) | |
{ | |
AVAssetTrack *track; | |
if([tracks count] > 0) | |
{ | |
track = tracks[0]; | |
if(track != nil) | |
{ | |
return track.naturalSize; | |
} | |
} | |
else | |
{ | |
NSLog(@"Warning: Unable to retrieve video natural size on %@", path); | |
} | |
} | |
return CGSizeZero; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment