1

I want to have a shatter-like effect on a video playing (based on AVPlayer) which will transition to either another video or an image.

Is it possible to create this effect in iOS5/6 on this kind of video?
If not, an alternative would be to perform the transition on a still image of the last played frame. What would be the most appropriate framework for this? CoreImage? CoreGraphics? OpenGL?

ESoft
  • 852
  • 1
  • 8
  • 21

4 Answers4

2

I think that putting a UIVIew over the video is going to be your best option here. You could then use Quartz2d (or even OpenGL ES) if you really need performance for drawing in the view (thus, over the video).

With Quarz2d you could compose a simple sprite-sheet (common technique used in games) with all the frames for your shatter animation, and just loop through them and present them over the aforementioned UIView. If performance is not good enough, you could try using OpenGL ES :), but you could save a lot of time by using Quarz2d.

If performance would be an issue, you could end up using a Cocos2D layer on top of your video, like in this post, where the goal was to render a particle emitter on top of the video... Cocos2d ( OpenGL ES ) solved the performance issues. ( The good thing is that Cocos2d can easily handle sprite sheets so I'm guessing you could implement this in no time )

In short: Depending on how big your transition is, pick either OpenGL ES (if you want that performance) or Quarz2d if performance is not a big issue.

Cheers.

Community
  • 1
  • 1
Goles
  • 11,599
  • 22
  • 79
  • 140
1

If you just want the transition between different videos during playback, you can use view transitions to switch between the videos. I am not sure exactly how your animation should look, but here is an example. It is important to preload the other video in time and check that the video is ready for display before starting the transition, otherwise it will not look good.

If you want to create some really advanced effects, another option would be to render the video files to OpenGL ES textures and use GL to create basically any 3D effect you could think of. I have written a small POC of this, that I can share if you are interested. See also this question.

If you want to persist the transition to a video file, you need to manipulate the videos frame-by-frame and create a new video stream from it. This is more complicated, but the AVFoundation API can do it. Here is an example.

Community
  • 1
  • 1
Krumelur
  • 31,081
  • 7
  • 77
  • 119
1

I've used this technique before all I did was grab an Image of the very last frame of the video, put it behind the video. When video has stopped playing, remove the video player from the view and perform the shatter animation on the image which would reveal what is behind it

CStreel
  • 2,642
  • 2
  • 19
  • 37
1

Hi add view of mpmoviecontroller on viewcontroller's view and at place a image view and get some images (sequence of image for sutter) and play animation of those images for show shutter effect. Hopefully this trick will work for you :)

For uiimageview animaton check out this link

UIImageView Animation

abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31
  • Depending on the number of images that the user wants to display in the sequence this could really harm the performance of the video being played in the AVPlayer (lag/choppiness). Assuming it's at least 24 frames per second, I really think this solution won't cut it in this case. – Goles Oct 22 '12 at 15:29