for days now I am trying to solve this, apparently I just can't get affine transforms.
Basically, I would like to rotate a movie multiple times by 90 degrees. There is a good example here:
Rotating Video w/ AVMutableVideoCompositionLayerInstruction
but this works only for the first rotation, while I would like to rotate it from portrait to landscape, back to portrait, back to landscape.
Whatever I tried, I get absolutely weird results. Unfortunately, even after much reading, my understanding of affine transforms obviously did not improve either.
So I am basically asking for a layout of an algorithm which will
- rotate the layer of an AVMutableVideoComposition by 90 degrees, regardless of its current orientation.
- Apply a translation to move the layer into the center.
This should be called each time I click on a button.
But whatever I try, the layer is rotating correctly, but the translation is moving the layer out of the center. What is the right way to do this?