I am merging the video using AVMutableComposition and the videos gets merged.But the video gets stored in the landscape (which is default mode for AVAsset) after merging.So i want the video to be fix in portrait mode only...Is there any way to set the video orientation to portrait mode. Thanx in advance
Here is the code i used for merging the video
NSArray *arrVideoUrl=[objApp.dictSelectedVideos allKeys];
NSMutableArray *arrVideoAsset=[[NSMutableArray alloc]init];
for (int i=0; i<objApp.dictSelectedVideos.count; i++) {
AVURLAsset *video=[[AVURLAsset alloc]initWithURL:[arrVideoUrl objectAtIndex:i] options:nil];
[arrVideoAsset addObject:video];
}
AVURLAsset *music_track=[[AVURLAsset alloc]initWithURL:songUrl options:nil];
//to mix up the media items
AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];
//Setting Audio track
AVMutableCompositionTrack *AudioTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
//setting the track to add the videos
AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
AVURLAsset *tempVideo1=[arrVideoAsset objectAtIndex:0];
AVURLAsset *tempVideo2=[arrVideoAsset objectAtIndex:1];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, tempVideo1.duration)ofTrack:[[tempVideo1 tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];
if (arrVideoUrl.count==1)
{
[AudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, CMTimeAdd(kCMTimeZero, tempVideo2.duration))ofTrack:[[music_track tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] atTime:kCMTimeZero error:nil];
}
else{
for (int j=1; j<=arrVideoAsset.count-1; j++)
{
AVURLAsset *tempVideoNext=[arrVideoAsset objectAtIndex:j];
AVURLAsset *tempVideoPrev=[arrVideoAsset objectAtIndex:j-1];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, tempVideoNext.duration)ofTrack:[[tempVideoNext tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:tempVideoPrev.duration error:nil];
}
[AudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, CMTimeAdd(tempVideo1.duration, tempVideo2.duration))ofTrack:[[music_track tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] atTime:kCMTimeZero error:nil];
}