在上传到网络服务器之前如何旋转 UIImagePickerController 中的视频
使用 UIImagePickerController 选择视频后,我将视频上传到网络服务器。但是,使用横向相机拍摄的视频在服务器上是反转的。我想在上传之前使用 AVFoundation 旋转视频。我已经弄清楚如何使用 AVAsset 获取视频的大小和首选旋转。现在我需要在上传之前对视频应用仿射变换。
以下是 LandscapeRight 视频的大小和变换示例:
2011-01-07 20:07:30.024 MySecretApp[1442:307] size.width = 1280.000000 size.height = 720.000000 2011-01-07 20:07:30.027 MySecretApp[1442:307] txf.a = -1.000000 txf.b = 0.000000 txf.c = 0.000000 txf.d = -1.000000 txf.tx = 1280.000000 txf.ty = 720.000000
如何我转换视频以撤消反转?我假设我必须将结果导出到一个新文件并将其上传到网络服务器。我还必须对纵向拍摄的视频进行类似的转换,以将它们从横向旋转,以便它们在服务器上正确定位。
谢谢
I'm uploading videos to a web server after choosing the video using the UIImagePickerController. However, videos shot with the camera in landscapeRight orientation are inverted on the server. I want to use AVFoundation to rotate the video before uploading. I've figured out how to get the size and preferredRotation of the video using AVAsset. Now I need to apply an affine transform to the video before uploading.
Here's an example of the size and transform from a landscapeRight video:
2011-01-07 20:07:30.024 MySecretApp[1442:307] size.width = 1280.000000 size.height = 720.000000 2011-01-07 20:07:30.027 MySecretApp[1442:307] txf.a = -1.000000 txf.b = 0.000000 txf.c = 0.000000 txf.d = -1.000000 txf.tx = 1280.000000 txf.ty = 720.000000
How would I transform the video to undo the inversion? I assume that I'd have to export the results to a new file and upload that to the webserver. I'll also have to do a similar conversion to videos shot in portrait to rotate them from landscape so that they are orientated correctly on the server.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ffmpeg 怎么样,它可以作为库链接到您的 iPhone 应用程序中?
这是一个重复的问题,其中详细介绍了 ffmpeg 解决方案。
How about using ffmpeg, which can be included as a library linked into your iPhone app?
Here's a duplicate question with the ffmpeg solution detailed.