ios - CAKeyframeAnimation doesn't animate after exporting video -


i have big problem cakeyframeanimation. there function create selected animation after selected user. data in prepared dictionary. there code:

        //prepare settings         let settings = datamanager.getfreeeffectssettingsforfilename("")          //set origin         let freeeffectorigin = settings.objectforkey("freeeffectorigin") as! [string: nsnumber]         let xorigin: nsnumber = freeeffectorigin["x"]! nsnumber         let yorigin: nsnumber = freeeffectorigin["y"]! nsnumber          //set size         let freeeffectsize = settings.objectforkey("freeeffectsize") as! [string: nsnumber]         let widthsize: nsnumber = freeeffectsize["width"]! nsnumber         let heightsize: nsnumber = freeeffectsize["height"]! nsnumber          //set frame origin , size         freeeffectanimationimage = uiimageview(frame: cgrectmake(cgfloat(xorigin), cgfloat(yorigin), cgfloat(widthsize), cgfloat(heightsize)))         freeeffectanimationimage.image = datamanager.getfreeeffectsimagesforfilename("")[0] as? uiimage          //set begining point         let freeeffectbeginingpoint = settings.objectforkey("beginingpoint") as! [string: nsnumber]         let xbeginingpoint: nsnumber = freeeffectbeginingpoint["x"]! nsnumber         let ybeginingpoint: nsnumber = freeeffectbeginingpoint["y"]! nsnumber          beginingpoint = cgpointmake(cgfloat(xbeginingpoint), cgfloat(ybeginingpoint))          //set ending point         let freeeffectendingpoint = settings.objectforkey("endingpoint") as! [string: nsnumber]         let xendingpoint: nsnumber = freeeffectendingpoint["x"]! nsnumber         let yendingpoint: nsnumber = freeeffectendingpoint["y"]! nsnumber          endingpoint = cgpointmake(cgfloat(xendingpoint), cgfloat(yendingpoint))          freeeffectanimationimage.center = beginingpoint          freeeffectanimationview.addsubview(freeeffectanimationimage)          let animationcgimagesarray = nsmutablearray()         let animationimages = datamanager.getfreeeffectsimagesforfilename("") as! [uiimage]          image: uiimage in animationimages {             animationcgimagesarray.addobject(image.cgimage!)         }          let animation = cakeyframeanimation(keypath: "contents")         animation.calculationmode = kcaanimationdiscrete         //animation.begintime = 0.1         animation.duration = 2.5         animation.repeatcount = 50         //animation.keytimes = [0.0, 0.4, 0.7, 1.0]         animation.autoreverses = false         animation.values = animationcgimagesarray [anyobject]         animation.removedoncompletion = false         animation.fillmode = kcafillmodeforwards          freeeffectanimationimage.layer.addanimation(animation, forkey: "contents") 

after user can save animation , layer on video. there method layering movie:

videosaver.savevideo(videoasset!) {         (composition, size) in         ////////////////         //parent layer//         ////////////////          let parentlayer = calayer()         parentlayer.frame = cgrectmake(0, 0, size.width, size.height)          ///////////////         //video layer//         ///////////////         let videolayer = calayer()         videolayer.frame = cgrectmake(0, 0, size.width, size.height)          //////////////////////////         //animation layout layer//         //////////////////////////         let animationoverlaylayer = avsynchronizedlayer()         animationoverlaylayer.contents = self.freeeffectanimationimage.image?.cgimage         animationoverlaylayer.addanimation(self.freeeffectanimationimage.layer.animationforkey("contents")!, forkey: "contents")         animationoverlaylayer.frame = cgrectmake(self.beginingpoint.x, self.beginingpoint.y, cgrectgetwidth(self.freeeffectanimationimage.frame), cgrectgetheight(self.freeeffectanimationimage.frame))         animationoverlaylayer.maskstobounds = true          ///////////////////////////////////////////////          parentlayer.addsublayer(videolayer)         if self.freeeffectanimationimage.hidden == false {             parentlayer.addsublayer(animationoverlaylayer)         }          ///////////////         //composition//         ///////////////         composition.animationtool = avvideocompositioncoreanimationtool.init(postprocessingasvideolayer: videolayer, inlayer: parentlayer)     } 

sorry long code stuck on , must finish on monday. if me glad.

uf, fixed it. problem because not specify begintime. there code:

let animation = cakeyframeanimation(keypath: "contents")         animation.calculationmode = kcaanimationdiscrete         animation.duration = 2.5         animation.repeatcount = 50         animation.autoreverses = false         animation.values = animationcgimagesarray [anyobject]         animation.removedoncompletion = false         animation.fillmode = kcafillmodeforwards         animation.begintime = avcoreanimationbegintimeatzero          freeeffectanimationimage.layer.addanimation(animation, forkey: "contents") 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -