我正在合并多个视频,我想检测哪些视频处于纵向模式并在横向模式下旋转它们,以便所有电影都处于横向模式......除了实际旋转之外,我已经完成了所有工作并且工作得很好,我想这与旋转中心或组合旋转。
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 比例拟合解决方案不感兴趣,我希望视频在使用 AVAssetExportSession 导出之前保持尽可能高的分辨率。
像这样的解决方案:
CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(degreesToRadians(90.0));
CGAffineTransform rotateTranslate = CGAffineTransformTranslate(rotateTransform,320,0);
不适合我的需要,因为我已经尝试过了。你有什么想法?一些帮助将不胜感激。