Rotating Video with AVMutableVideoCompositionLayerInstruction

前端 未结 5 1449
一向
一向 2021-02-01 08:32

I\'m shooting video on an iPhone 4 with the front camera and combining the video with some other media assets. I\'d like for this video to be portrait orientation - the default

5条回答
  •  执笔经年
    2021-02-01 09:20

    Try this:

    AVMutableVideoCompositionLayerInstruction *passThroughLayer = AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
    CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(degreesToRadians(90.0));
    CGAffineTransform rotateTranslate = CGAffineTransformTranslate(rotateTransform,320,0);
    [passThroughLayer setTransform:rotateTranslate atTime:kCMTimeZero];
    

    Essentially the idea is to create a rotation and translation matrix. You rotate it to the proper orientation and then translate it into the view. I did not see any way to specify a center point while I was glancing through the API.

提交回复
热议问题