Giter Club home page Giter Club logo

mttransitions's Introduction

MTTransitions

Transitions ports from GL-Transitions to Metal.

Features

  • Up to 76 transitions
  • Image Transitions
  • UIView Transitions
  • UIViewController Push Transtions
  • UIViewController Present Transitions
  • Video Merge Transitions
  • Create video from images with transitions
  • Create video from images with transitions and background music

Requirements

  • iOS 10.0 +
  • Xcode 11.0 +
  • Swift 5.0 +

Transitions

Support Following Transitions:

  • MTAngularTransition
  • MTBounceTransition
  • MTBowTieHorizontalTransition
  • MTBowTieVerticalTransition
  • MTBurnTransition
  • MTButterflyWaveScrawlerTransition
  • MTCannabisleafTransition
  • MTCircleCropTransition
  • MTCircleTransition
  • MTCircleOpenTransition
  • MTColorPhaseTransition
  • MTColourDistanceTransition
  • MTCrazyParametricFunTransition
  • MTCrossZoomTransition
  • MTCrossHatchTransition
  • MTCrossWarpTransition
  • MTCubeTransition
  • MTDirectionalTransition
  • MTDirectionalWarpTransition
  • MTDirectionalWipeTransition
  • MTDisplacementTransition
  • MTDoomScreenTransition
  • MTDoorwayTransition
  • MTDreamyTransition
  • MTDreamyZoomTransition
  • MTFadeTransition
  • MTFadeColorTransition
  • MTFadegrayscaleTransition
  • MTFlyeyeTransition
  • MTGlitchDisplaceTransition
  • MTGlitchMemoriesTransition
  • MTGridFlipTransition
  • MTHeartTransition
  • MTHexagonalizeTransition
  • MTInvertedPageCurlTransition
  • MTKaleidoScopeTransition
  • MTLinearBlurTransition
  • MTLumaTransition
  • MTLuminanceMeltTransition
  • MTMorphTransition
  • MTMosaicTransition
  • MTMultiplyBlendTransition
  • MTPerlinTransition
  • MTPinwheelTransition
  • MTPixelizeTransition
  • MTPolarFunctionTransition
  • MTPolkaDotsCurtainTransition
  • MTRadialTransition
  • MTRandomSquaresTransition
  • MTRippleTransition
  • MTRotateScaleFadeTransition
  • MTSimpleZoomTransition
  • MTSquaresWireTransition
  • MTSqueezeTransition
  • MTStereoViewerTransition
  • MTSwapTransition
  • MTSwirlTransition
  • MTTangentMotionBlurTransition
  • MTTVStaticTransition
  • MTUndulatingBurnOutTransition
  • MTWaterDropTransition
  • MTWindTransition
  • MTWindowBlindsTransition
  • MTWindowSliceTransition
  • MTWipeDownTransition
  • MTWipeLeftTransition
  • MTWipeRightTransition
  • MTWipeUpTransition
  • MTZoomInCirclesTransition

Installation

MTTransitions is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod MTTransitions

Get Started

Each transition requires two input MTIImage. Image should be .oriented(.downMirrored).

import MTTransitions

let transition = MTBounceTransition()
transition.inputImage = <from Image>
transition.destImage = <to Image>

// animate progress from 0.0 to 1.0

imageView.image = transition.outputImage

UIView Transition

let effect = MTPerlinTransition()

MTTransition.transition(with: view, effect: effect, animations: {
    // Do your animation to your view
}) { (_) in
    // Transition completed
}

UIViewController Push Transition

class PushAViewController: UIViewController {

    private let transition = MTViewControllerTransition(transition: MTBurnTransition())
    
    // ...
}

extension PushAViewController: UINavigationControllerDelegate {
    
    func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        if operation == .push {
            return transition
        }
        return nil
    }
}

UIViewController Present Transition

class PresentAViewController: UIViewController {

    // ...
    
    let vc = PresentBViewController()
    vc.modalPresentationStyle = .fullScreen
    vc.transitioningDelegate = self
    present(vc, animated: true, completion: nil)
}

extension PresentAViewController: UIViewControllerTransitioningDelegate {
    
    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return transtion
    }
    
    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return transtion
    }
}

Video Transition

MTTransitions also support merging videos with transitions.

  • Support merge multiple video files
  • Support multiple transition effects
  • Support different multiple render size.
  • Support passthrough transition.
// pick one transtion effect
let effect = MTTransition.Effect.wipeLeft
let duration = CMTimeMakeWithSeconds(2.0, preferredTimescale: 1000)
try? videoTransition.merge(clips,
                           effect: effect,
                           transitionDuration: duration) { [weak self] result in

    guard let self = self else { return }
    let playerItem = AVPlayerItem(asset: result.composition)
    playerItem.videoComposition = result.videoComposition
    
    self.player.seek(to: .zero)
    self.player.replaceCurrentItem(with: playerItem)
    self.player.play()
}

Please refer VideoTransitionSampleViewController and MultipleVideoTransitionsViewController for more details.

Create Video From Images

MTMovieMaker support create video from a sequence images with transitions. You can also pass a local audio file url to MTMovieMaker to create background music.

let fileURL = URL(fileURLWithPath: path)
movieMaker = MTMovieMaker(outputURL: fileURL)
do {
    try MTMovieMaker?.createVideo(with: images, effects: effects) { result in
        switch result {
        case .success(let url):
            print(url)
        case .failure(let error):
            print(error)
        }
    }
} catch {
    print(error)
}

mttransitions's People

Contributors

alexiscn avatar csenazmulbubt avatar danieleke avatar yyjim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mttransitions's Issues

Can not start writing

Fatal error: Can not start writing: file MTTransitions/MTMovieMaker.swift, line 130

Exported video does not have transition

Hi

I'm using this library with swift. Video is well playing with AVPlayer but when I use MTVideoExporter to save video it does not contain transition, frames between video display as black screen. Any help will be appreciated

Thanks
Saba

Doesn't compile

Incorrect argument label in call (have 'cgImage:isOpaque:', expected '__cgImage:isOpaque:')
Replace 'cgImage' with '__cgImage'

MetalPetal Video filter not working on transition

I want to use filter on video. thats why is use VideoIO. filter work but the problem is transition.
` func videoFilterSet(){
guard let result = result else{
return}

    let context = try! MTIContext(device: MTLCreateSystemDefaultDevice()!)
    let handler = MTIAsyncVideoCompositionRequestHandler(context: context, tracks: result.composition.tracks, on: .main) { request in
        self.filter.inputImage = request.anySourceImage
        return self.filter.outputImage!
    }
    let composition = VideoComposition(propertiesOf: result.composition, compositionRequestHandler: handler.handle(request:))
    let playerItem = AVPlayerItem(asset: result.composition)
    playerItem.videoComposition = composition.makeAVVideoComposition()
    player.replaceCurrentItem(with: playerItem)

    self.player.seek(to: .zero)
    self.player.replaceCurrentItem(with: playerItem)
    self.player.play()
}`

please see this code for filter

Video processing

Hello,

I'd like to merge two videos using these transitions. There is only MTIImage and I can't use the transitions for video processing.
Please let me know how to implement the video transitions.

Thank you.

Cannot Provide Dynamic duration to each image.

Hi , i am using this library and its way too good but i am stuck when trying to add dynamic duration to each image in array
for example there are 6 images and adding duration to each image like [0.0,4.0,2.0,0.5,5.0,6.0].
it only works fine when i am adding static duration for all images like [2.0], then all images duration will be 2.0.

Pleas help me to provide flexible duration for each image while creating video of images.

Below is the Error:-

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16364), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x28023c5a0 {Error Domain=NSOSStatusErrorDomain Code=-16364 ["(null)"}}``](url
Screenshot 2022-07-12 at 4 29 55 PM
)

Need to change orientation of video

Hello Team,

you made great example of transition between videos but when I use your library its always gives me wrong orientation video. can you please help me for the same.

Thanks in advance

video clearity low

when create video from images and change frame duratio 1.0 to 7.0 ... video represent with very low clearity. Please tell me what should i do ?

[MTVideoTransition] Issue related to memory leak

Hello,

I'm using the library to make transitions between clips. It works fine 1 or 2 times, but after that I have a crash related to memory. I can see the memory inspector which increases the memory leaks after each processing. I'm using the merge function.

Create Video From Images with transition

i run your code but this is not working for Create Video From Images with transition, it just blinking only one image, i try to fix it but not getting done by me, so i request you to provide this solution. please look 'MTMovieMaker' class, thanks,

导出会报"Source frame missing"

Metal API Validation Enabled
Export error:Error Domain=AVFoundationErrorDomain Code=-11858 "Source frame missing" UserInfo={NSUnderlyingError=0x280250db0 {Error Domain=NSOSStatusErrorDomain Code=-12500 "(null)"}, NSLocalizedFailureReason=The video could not be composited., NSDebugDescription=Source frame missing, NSLocalizedDescription=Operation Stopped}

MTVideoTransition outputs in wrong orientation

I'm trying to use this library to add transitions between movie clips selected by the user but it doesn't apply the correct video orientation to the output.

TLDR: i'm selecting 2 portrait videos and the output shows them in landscape with the transition effect in portrait.

crash

'Invalid parameter not satisfying: [kernel.alphaTypeHandlingRule _canHandleAlphaTypesInImages:images]'

Can not create video with image of different sizes.

please, solve this issue , i want to create video from images of different size but i cant do that. video only create with first image size, and all images are can not scal to fit in video frame. give me some suggestion what should i do.

Zoom in out Transition

Dear Sir,
How to make zoom in/out animation for every transition like show in iMovie app?
thanks,

Contribution and suggestions

Hi @alexiscn

Great job on MTTranstions! Do you have any upcoming plans for additional features?

I was considering to work on a similar project, but it would make more sense to contribute in your repository if you're still actively developing it.

I think these transitions could be used in a high-level context, similarly to the UIViewController transitions which you've already implemented. My idea would be to create an UIKit compatible transition effect which could be applied on any UIView subclass.

If you are interested let me know and I could share an example here!

Objective-C

你好,我想知道OC环境的项目想接入MTTransitions,怎么调用库里面的方法,想知道有OC的Demo吗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.