我与其他video合并后将video上传到服务器,但录制的video顺时针旋转

合并代码 –

AVAsset * firstAsset = [AVAsset assetWithURL:urlIntroVideo]; AVAsset * secondAsset = [AVAsset assetWithURL:recordedVideoUrl];

if(firstAsset!= nil && secondAsset!= nil){// [[AppDelegate Getdelegate] showIndicator]; // 1 – 创buildAVMutableComposition对象。 这个对象将保存你的AVMutableCompositionTrack实例。 AVMutableComposition * mixComposition = [[AVMutableComposition alloc] init]; // 2 – video轨道

/******************************************************************************** --------------->> VIDEO MERGING TRACK <<-------------------- ********************************************************************************/ AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; NSArray *videoTracks = [NSArray arrayWithArray: [firstAsset tracksWithMediaType:AVMediaTypeVideo]]; NSLog(@"Video Tracks count 1st Assest=> %ld",[videoTracks count]); NSArray *audioTracks = [NSArray arrayWithArray: [firstAsset tracksWithMediaType:AVMediaTypeAudio]]; NSLog(@"Auido Tracks count => %ld",[audioTracks count]); [firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration) ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] 

atTime:kCMTimeZero error:nil];

 [firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, secondAsset.duration) ofTrack:[[secondAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] 

atTime:firstAsset.duration error:nil];

NSString * bundleDirectory = [[NSBundle mainBundle] bundlePath];

 NSString *potrait_intro = [bundleDirectory stringByAppendingPathComponent:@"silent08s.mp3"]; NSURL *potrait_intro_url = [NSURL fileURLWithPath:potrait_intro]; AVAsset *audioAssest=[AVAsset assetWithURL:potrait_intro_url]; AVMutableCompositionTrack *audioTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio 

preferredTrackID:kCMPersistentTrackID_Invalid];

 NSArray *audioTracksSilent = [NSArray arrayWithArray: [audioAssest tracksWithMediaType:AVMediaTypeAudio]]; [audioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, audioAssest.duration) ofTrack:([audioTracksSilent count]>0)?[audioTracksSilent objectAtIndex:0]:nil atTime:kCMTimeZero error:nil]; NSArray *audioTracks2 = [NSArray arrayWithArray: [secondAsset tracksWithMediaType:AVMediaTypeAudio]]; NSLog(@"Auido Tracks count => %ld",[audioTracks2 count]); [audioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, secondAsset.duration) ofTrack:[[secondAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] atTime:audioAssest.duration error:nil]; // // NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:[NSString 

stringWithFormat:@“final_merged_video-%d.mov”,arc4random()%1000]];

 NSURL *url = [NSURL fileURLWithPath:myPathDocs]; // 5 - Create exporter AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetHighestQuality]; exporter.outputURL=url; exporter.outputFileType = AVFileTypeQuickTimeMovie; exporter.shouldOptimizeForNetworkUse = YES; [exporter exportAsynchronouslyWithCompletionHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ [[AppDelegate Getdelegate] hideIndicator]; [self exportDidFinish:exporter]; }); }]; } 

请帮我解决这个问题

当你合并了两个video和/或你的服务器无法处理它时,你可能会丢失AVAsset上的旋转信息。 你需要做的是获得旋转信息(你可以使用这个例子: https : //gist.github.com/lukabernardi/5020724 ),然后相应地旋转video之前,发送到服务器。