I am playing a movie using an AVPlayer and animating 500 falling particles on top. I tried to simply add 500 animated CALAyers. I tried several variations on that but performance is always a problem. As soon as I get more then around 100 CALayers, the video gets choppy. What would be the proper way to do this? I thought maybe this should be done using OpenGL, but I never used it and can't find how to have a video played in OpenGL. I can get the background videos as separate frame pngs, but being fullscreen, the content size gets quite big quite fast.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
Try drawing the particles into a much smaller number of CALayers, multiple particles per layer bitmap, one for each speed of falling, etc. Then redraw the layers in background threads as needed so as not to impact the composited on video frame rate.
We ended up running an OpenGL layer using Cocos2D over our video animation. The performance was impacted a little but for our need, it was alright.
Take a look at this post Alternatives to creating an openGL texture from a captured video frame to overlay an openGL view over video? (iPhone). Brad shows how to render video to OpenGL textures. You can then render your particles over a video textured plane. For interaction, you could integrate a physics engine such as Bullet to exert forces to areas of the screen to interact with the particles.
If you can wait, I think this will get much easier (video to texture stream) in iOS5.