Programmatically access orientation of an iPhone video

人盡茶涼 提交于 2019-12-20 05:26:10

问题


I need to access a video returned by the UIImagePickerController and know if it was recorded portrait or landscape. I've seen references to mov_read_tkhd but I'm not sure if that will do the job, or indeed how to include the necessary libraries.


回答1:


On iOS 4 and above, with 3GS/3rd gen iTouch or better, you can use the new AVFoundation libraries.

Something like:

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


来源:https://stackoverflow.com/questions/2814626/programmatically-access-orientation-of-an-iphone-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!