Rotating Video with AVMutableVideoCompositionLayerInstruction

前端 未结 5 1464
一向
一向 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:12

    AVAssetTrack *videoAssetTrack= [[videoAsset tracksWithMediaType:AVMediaTypeVideo] lastObject];
    
    AVMutableCompositionTrack *videoCompositionTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
    [videoCompositionTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:videoAssetTrack atTime:kCMTimeZero error:&error];
    
    videoCompositionTrack.preferredTransform = videoAssetTrack.preferredTransform;
    

提交回复
热议问题