Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I) Before merging, we take the videos URLs(static videos or camera captured videos) from array, and store them into assets.

II) In the processing of storing the URLs into assets,

1) First, we take the first URL into 'firstVideoAsset', after that we take second URL into 'secondVideoAsset'. Then merge the two videos and store the merged URL into again 'firstVideoAsset'.

2) After that, take the take third URL into 'secondVideoAsset'. Them merge the two videos. Same process will go on until the loop ends.
3) Send the final merged URL into MPMoviePlayerController to play the 'preview' of the merged video.

Orientation issue:-

1) While in the merging process, if we capture the video in 'landscape' orientation(i.e. LandscapeLeft), the captured video after merging, is coming in 'Upside-down' mode(i.e. reverse of captured video).

2) The sizes of all the videos(static or camera captured) are not coming in same size after merging.

3) If we capture the video using front camera, after merging all, the captured videos are coming in upside down.

Need help from your side:-

1) Before merging, if we capture the videos in any orientation mode, they have to come in only one orientation(i.e. LandscapeLeft or LandscapeRight) mode after merging.

2) After merging all the videos, the sizes(height and width) of all the videos(static or camera captured) in any orientation mode, should come in same sizes.

3) While using front camera, if we capture the video in Landscape left mode, after merging all the videos, the captured videos will come correct mode. But, when capture the video in Landscape right mode, the captured videos after merging all the videos will come in Upside down.(i.e. Reverse of original captured video).

4) While using back camera, if we capture the video in Landscape left mode, after merging all the videos, the captured videos will come in Upside down.(i.e. Reverse of original captured video) . But, when capture the video in Landscape right mode, the captured videos after merging all the videos will come in correct mode.
Posted
Updated 2-Feb-17 20:51pm

1 solution

You can check the orientation of the video run time in above code while you create object for AVMutableVideoCompositionInstruction.


Objective-C
AVMutableVideoCompositionInstruction *instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [mutableComposition duration]);
AVAssetTrack *videoTrack = [[mutableComposition tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];

AVMutableVideoCompositionLayerInstruction * layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];

UIImageOrientation videoAssetOrientation_  = UIImageOrientationUp;
BOOL  isVideoAssetPortrait_  = NO;
CGAffineTransform videoTransform = assetVideoTrack.preferredTransform;

if(videoTransform.a == 0 && videoTransform.b == 1.0 && videoTransform.c == -1.0 && videoTransform.d == 0)
{
    videoAssetOrientation_= UIImageOrientationRight;
    isVideoAssetPortrait_ = YES;
}
if(videoTransform.a == 0 && videoTransform.b == -1.0 && videoTransform.c == 1.0 && videoTransform.d == 0)
{
    videoAssetOrientation_ =  UIImageOrientationLeft;
    isVideoAssetPortrait_ = YES;
}

CGFloat FirstAssetScaleToFitRatio = 320.0 / assetVideoTrack.naturalSize.width;
if(isVideoAssetPortrait_)
{
    videoSize=CGSizeMake(350,400);
    FirstAssetScaleToFitRatio = 320.0/assetVideoTrack.naturalSize.height;
    CGAffineTransform FirstAssetScaleFactor = CGAffineTransformMakeScale(FirstAssetScaleToFitRatio,FirstAssetScaleToFitRatio);
    [layerInstruction setTransform:CGAffineTransformConcat(assetVideoTrack.preferredTransform, FirstAssetScaleFactor) atTime:kCMTimeZero];
}
else
{
    videoSize=CGSizeMake(assetVideoTrack.naturalSize.width,assetVideoTrack.naturalSize.height);
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900