How can I set the UIImagePickerController orientation for video?

做~自己de王妃 提交于 2019-11-30 20:58:50

问题


My app uses the UIImagePickerController to record a video, and I'm then uploading it to our Amazon server using ASIS3Request.

Whilst the video always plays in the correct orientation on the device, the orientation is wrong when viewed in some browsers.

Is there a way for me to manually set the orientation of the phone onto the image file when it's being taken? Or is the problem exclusively with the browsers (and if so, how can I fix that)?

Thank you. S.O. for president!

Duncan


回答1:


the iPhone sets the orientation in the exif data of the video. It will play back just fine in quicktime, but everywhere else has it rotated wrong.

There are two ways to solve it, rotate it on device, or up in the cloud. You can ask the video for it's preferred transform on the device and that will let you know what you need to rotate it.

   AVURLAsset * footageVideo = [AVURLAsset URLAssetWithURL:assetURL options:nil];
   AVAssetTrack * footageVideoTrack = [footageVideo compatibleTrackForCompositionTrack:videoTrack];

   CGAffineTransform t = footageVideoTrack.preferredTransform;

Once you have the transform you can use an AVExportSession to rotate the video, although this can take quite some time on device.



来源:https://stackoverflow.com/questions/9193451/how-can-i-set-the-uiimagepickercontroller-orientation-for-video

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