ios – GPUImageMovie不尊重imageOrientation

ios – GPUImageMovie不尊重imageOrientation,第1张

概述我正在使用正在播放电影文件的GPU ImageMovie,这个文件是在iOS设备上录制的. 但是,当GPUImageMovie播放时,它的方向错误,因此视频不会旋转以便正确显示. 我如何让它尊重它的方向?我试过没有运气修改OpenGL代码. 使用GPUImageMovie播放在iOS设备中录制的视频时遇到同样的问题.我用以下函数解决了它: 通过传递过滤器来调用此setRotationForFilt 我正在使用正在播放电影文件的GPU ImageMovIE,这个文件是在iOS设备上录制的.

但是,当GPUImageMovIE播放时,它的方向错误,因此视频不会旋转以便正确显示.

我如何让它尊重它的方向?我试过没有运气修改OpenGL代码.

解决方法 使用GPUImageMovIE播放在iOS设备中录制的视频时遇到同样的问题.我用以下函数解决了它:

通过传递过滤器来调用此setRotationForFilter:方法. orIEntationForTrack:将返回您当前的视频方向.

- (voID)setRotationForFilter:(GPUImageOutput<GPUImageinput> *)filterRef {    UIInterfaceOrIEntation orIEntation = [self orIEntationForTrack:self.playerItem.asset];    if (orIEntation == UIInterfaceOrIEntationPortrait) {        [filterRef setinputRotation:kGPUImageRotateRight atIndex:0];    } else if (orIEntation == UIInterfaceOrIEntationLandscapeRight) {        [filterRef setinputRotation:kGPUImageRotate180 atIndex:0];    } else if (orIEntation == UIInterfaceOrIEntationPortraitUpsIDeDown) {        [filterRef setinputRotation:kGPUImageRotateleft atIndex:0];    }}- (UIInterfaceOrIEntation)orIEntationForTrack:(AVAsset *)asset{    AVAssetTrack *vIDeoTrack = [[asset tracksWithMediaType:AVMediaTypeVIDeo] objectAtIndex:0];    CGSize size = [vIDeoTrack naturalSize];    CGAffinetransform txf = [vIDeoTrack preferredtransform];    if (size.wIDth == txf.tx && size.height == txf.ty)        return UIInterfaceOrIEntationLandscapeRight;    else if (txf.tx == 0 && txf.ty == 0)        return UIInterfaceOrIEntationLandscapeleft;    else if (txf.tx == 0 && txf.ty == size.wIDth)        return UIInterfaceOrIEntationPortraitUpsIDeDown;    else        return UIInterfaceOrIEntationPortrait;}

希望这能解决您的问题.

总结

以上是内存溢出为你收集整理的ios – GPUImageMovie不尊重imageOrientation全部内容,希望文章能够帮你解决ios – GPUImageMovie不尊重imageOrientation所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1058090.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存