我怎么可以设置视频的UIImagePickerController方向? [英] How can I set the UIImagePickerController orientation for video?

查看:294
本文介绍了我怎么可以设置视频的UIImagePickerController方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用的UIImagePickerController录制视频,而我则用ASIS3Request上传到我们的亚马逊的服务器。

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)?

感谢您。所以。为president!

Thank you. S.O. for president!

邓肯

推荐答案

iPhone的设置方向与视频的EXIF数据。这将回放就好在QuickTime,但其他地方有它旋转错误的。

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.

有两种方法解决,旋转的装置,或者在云端。你可以问视频为它的preferred设备上的变换,这将让你知道你需要旋转它的东西。

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;

一旦转换,你可以使用AVExportSession旋转视频,虽然这可能需要相当长的一段时间的设备。

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

这篇关于我怎么可以设置视频的UIImagePickerController方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆