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;
}
이렇게하면 문제가 해결됩니다.