Question

I am trying play and merge video. My application is only Landscape mode.

Problem When i pick recorded type video from the album. Video is rotated in the landscape mode.

I have tried all the answer on the stackoverflow but none of them working.

Here is my code

 AVMutableVideoCompositionLayerInstruction *passThroughLayer = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(degreesToRadians(90.0));
CGAffineTransform rotateTranslate = CGAffineTransformTranslate(rotationTransform,320,0);
[passThroughLayer setTransform:rotateTranslate atTime:kCMTimeZero];

AVMutableVideoCompositionInstruction *inst = 
            [AVMutableVideoCompositionInstruction videoCompositionInstruction];
inst.timeRange = CMTimeRangeMake(insertionTime, insertRange.duration);
inst.layerInstructions = [NSArray arrayWithObject:passThroughLayer];
[videoCompositionInstructions addObject:inst];
videoComposition.instructions = [NSArray arrayWithArray:videoCompositionInstructions];
Was it helpful?

Solution

I have just solved my question. Check if another facing this problem

 videoCompositionTrack.preferredTransform = videoTrack.preferredTransform;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top