Programmatically access orientation of an iPhone video

前端 未结 1 503
耶瑟儿~
耶瑟儿~ 2021-01-24 01:56

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 t

相关标签:
1条回答
  • 2021-01-24 02:37

    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
    
    0 讨论(0)
提交回复
热议问题