0 Replies
      Latest reply on Jan 27, 2020 12:50 AM by mkfromggn
      mkfromggn Level 1 Level 1 (0 points)

        How to add custom transition on video: Hello I am trying to add transition b/w video clip using AVMutableVideoCompositionLayerInstruction i am able to add only simple transition and not able to add any complex transition like ripple, reveal and etc.

        Please guide me how to add complex transition b/w video clip.

         

         

        Code snippet for Simple Transition b/w Video Clips:

         

        AVMutableVideoCompositionLayerInstruction *fromLayer;

        AVMutableVideoCompositionLayerInstruction *toLayer;

        if (i+1 < [ClipPath count])

                {

                    // Add transition from clip i to clip i+1.

                    AVMutableVideoCompositionInstruction *transitionInstruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];

                    transitionInstruction.timeRange = transitionTimeRanges[i];

                    fromLayer = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:compositionVideoTracks[alternatingIndex]];

           

                    toLayer = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:compositionVideoTracks[1-alternatingIndex]];

           

                    if ([transitionType isEqualToString:@"Multi-Push"]) {

               

                        if(i== 0){

                   

                            [fromLayer setTransformRampFromStartTransform:CGAffineTransformIdentity toEndTransform:CGAffineTransformMakeTranslation(videoWidth, 0.0) timeRange:transitionInstruction.timeRange];

                        }

                        else if (i == 1 )

                        {

                            [fromLayer setTransformRampFromStartTransform:CGAffineTransformMakeTranslation(0, 0) toEndTransform:CGAffineTransformMakeTranslation(0,0 - videoHeight) timeRange:transitionInstruction.timeRange];

                        }

                        else if (i == 2 ){

                   

                            [fromLayer setTransformRampFromStartTransform:CGAffineTransformMakeTranslation(0, 0) toEndTransform:CGAffineTransformMakeTranslation(0,videoHeight) timeRange:transitionInstruction.timeRange];

                        }

                        else{

                   

                            [fromLayer setTransformRampFromStartTransform:CGAffineTransformMakeTranslation(0, 0) toEndTransform:CGAffineTransformMakeTranslation(0 - (videoWidth),0) timeRange:transitionInstruction.timeRange];

                        }

               

                    }

        }

         

         

        Help in either Swift or Objective C Appreciated.

        Thank you in advance