Video rotated after applying AVVideoComposition

后端 未结 5 1347
野性不改
野性不改 2021-02-09 07:00

After applying an AVVideoComposition to my AVPlayerItem, the filter I apply does work, but the video gets rotated in the AVPlayerLayer.

5条回答
  •  野的像风
    2021-02-09 07:33

    Try this code below which worked for me

    // Grab the source track from AVURLAsset for example.
    let assetV = YourAVASSET.tracks(withMediaType: AVMediaTypeVideo).last
    
    // Grab the composition video track from AVMutableComposition you already made.
    let compositionV = YourCompostion.tracks(withMediaType: AVMediaTypeVideo).last
    
    // Apply the original transform.
    if ((assetV != nil) && (compostionV != nil)) {
        compostionV?.preferredTransform = (assetV?.preferredTransform)!
    }
    

    And then go ahead an export your video...

提交回复
热议问题