Iphone 使用AvmutableVideoCompositionLayerStruction的视频旋转

Iphone 使用AvmutableVideoCompositionLayerStruction的视频旋转,iphone,ios,avfoundation,cgaffinetransform,avmutablecomposition,Iphone,Ios,Avfoundation,Cgaffinetransform,Avmutablecomposition,我正在合并多个视频,我想检测哪些视频处于纵向模式,并在横向模式下旋转它们,以便所有电影都处于横向模式。。。我已经做了所有的事情,除了实际的旋转,我想这是一个旋转中心或合成旋转 AVMutableVideoCompositionLayerInstruction *videoTrackLayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAss

我正在合并多个视频,我想检测哪些视频处于纵向模式,并在横向模式下旋转它们,以便所有电影都处于横向模式。。。我已经做了所有的事情,除了实际的旋转,我想这是一个旋转中心或合成旋转

        AVMutableVideoCompositionLayerInstruction *videoTrackLayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:compositionVideoTrack];

        if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationPortrait)
        {
            CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI/2);
            //CGAffineTransform translateToCenter = CGAffineTransformMakeTranslation(640, 480);
            //CGAffineTransform mixedTransform = CGAffineTransformConcat(rotation, translateToCenter);
            [videoTrackLayerInstruction setTransform:rotation atTime:nextClipStartTime];
        }
        else if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationPortraitUpsideDown)
        {
            CGAffineTransform rotation = CGAffineTransformMakeRotation(-M_PI/2);
            [videoTrackLayerInstruction setTransform:rotation atTime:nextClipStartTime];
        }
        else if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationLandscapeLeft)
        {
            CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI);
            [videoTrackLayerInstruction setTransform:rotation atTime:nextClipStartTime];
        }
        else if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationLandscapeRight)
        {
            [videoTrackLayerInstruction setTransform:CGAffineTransformIdentity atTime:nextClipStartTime];
        }
如何正确旋转它们?我尝试了多个源,但都没有按它们应该的方式旋转它们。我对320 scale fit解决方案不感兴趣,我希望视频在使用AVAssetExportSession导出之前保持尽可能高的分辨率

这样的解决方案:

CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(degreesToRadians(90.0));
CGAffineTransform rotateTranslate = CGAffineTransformTranslate(rotateTransform,320,0);

不适合我的需要,因为我已经试过了。你有什么想法吗?非常感谢您的帮助。

您有没有想过这一点?我遇到了完全相同的问题。如果你不知道,请张贴答案对不起。。。仍然不能正常工作:(