How to fix video orientation issue in iOS

后端 未结 2 633
死守一世寂寞
死守一世寂寞 2020-12-14 04:15

I am working with an app in which user picks video from Photos and uploads it to server. As my server is .Net server , the video gets rotated. I know the reason of problem i

2条回答
  •  没有蜡笔的小新
    2020-12-14 04:46

    AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:@"your video url here..." options:nil];
    

    Add After AVMutableCompositionTrack.

    set setPreferredTransform: set here your source video that you want to export with same orientation.

     // Grab the source track from AVURLAsset for example.
    AVAssetTrack *assetVideoTrack = [videoAsset tracksWithMediaType:AVMediaTypeVideo].lastObject;
    
    // Grab the composition video track from AVMutableComposition you already made.
    AVMutableCompositionTrack *compositionVideoTrack = [mixComposition tracksWithMediaType:AVMediaTypeVideo].lastObject;
    
    // Apply the original transform.
    if (assetVideoTrack && compositionVideoTrack) {
            [compositionVideoTrack setPreferredTransform:assetVideoTrack.preferredTransform];
        }
    

提交回复
热议问题