如何控制使用 AVMutableComposition 组装的视频的方向
我正在整理一堆在 iPhone 上以纵向模式拍摄的视频剪辑。为了组装它们,我采用如下简单的方法:
AVURLAsset 来获取不同的视频,然后将它们推入 AVMutableCompositionTrack 中,然后将其放入 AVMutableComposition 中,我将使用 AVAssetExportSession 导出到文件中
我的问题是,当我开始显示时UIWebView 中的视频以横向模式显示。但是,如果我查看任何组件视图,它们就会以纵向视图显示。有谁知道如何确定方向。我尝试用 AVMutableComposition naturalSize 改变宽度和高度,但这只会让我的人看起来又矮又胖! (同时在他们这边)
提前感谢
都铎的任何想法/建议
I am assembling a bunch of video clips filmed on the iPhone in portrait mode. To assemble them I am taking straightforward approach as follows:
AVURLAsset to get hold of the different videos then shoving these into an AVMutableCompositionTrack and then putting this into an AVMutableComposition which I'm exporting to file with AVAssetExportSession
My problem is that when I come to display the video in a UIWebView, it is appearing in landscape mode. However, if I view any of the component views they appear in Portrait view. Does anyone know how to sort out the orientation. I tried messing around with the AVMutableComposition naturalSize changing the width and height around but that just made my people look short and fat! (whilst on their side)
Thanks in advance for any thoughts / suggestions
Tudor
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想要的只是保留视频方向,您可能需要从 AVAssetTrack 分配 AVMutableCompositionTrack prefferedTransition 值,如下所示:
If all you want is preserve you video orientation you may want to assign AVMutableCompositionTrack prefferedTransition value from AVAssetTrack like this:
设置将处理旋转+缩放的视频合成:
Setup a video composition that will handle rotate + scale:
以下是一些使用首选变换调整旋转的代码:
Here's some code that adjusted the rotation using the preferred transform: