以编程方式访问iPhone视频的方向

问题描述 投票:1回答:1

我需要访问UIImagePickerController返回的视频,并知道它是否是纵向或横向录制的。我已经看过对mov_read_tkhd的引用,但我不确定它是否可以完成这项工作,或者确实如何包含必要的库。

iphone objective-c video orientation
1个回答
1
投票

在iOS 4及更高版本上,使用3GS / 3rd gen iTouch或更高版本,您可以使用新的AVFoundation库。

就像是:

NSURL *url = // url to the video returned by the picker
AVAssetTrack *videoTrack = [[url tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
videoTrack.preferredTransform; // CGAffineTransform that tells you whether the video is rotated from original orientation
videoTrack.naturalSize; // CGSize that tells you the current dimensions of the video
© www.soinside.com 2019 - 2024. All rights reserved.