10

I have to figure out the best way to transition from one video to the next

BASIC IDEA: An example would be that there is a video of a person walking.....the user taps the video and a seamless transition occurs to a video of a person running (over simplified example)

My first thought was to create 2 movie players and use transitions between the 2 view elements. But movie-player doesn't support that.

stopping the current video, loading new content, and then starting it is a solution but not very elegant. We are making a interactive sales tool for our reps and we want this to look as professional as possible.

CURRENT THOUGHT: If there was some sample code for AVPlayer, it would seem I could use AVVideoComposition to switch between videos? But details on how that might happen don't seem to be currently available.

POSSIBLE CLUE: I figured this would be easy as I bought an app called Live Cams HD that shows 16 different video feeds at once.

Any ideas? Thanks in advance!

Steve Weintraut
  • 101
  • 1
  • 3
  • AVQueuePlayer which debuted in iOS 4.1 seemed like a natural solution but I'm still having problems getting a smooth transition from one clip to the next. – Ryan H. Feb 03 '11 at 12:56
  • Any progress with this issue? – Rizon Apr 13 '11 at 15:05
  • You have to set the actionAtItemEnd for the queue player to AVPlayerActionAtItemEndAdvance and have at least two copies of the same video (AVPlayerItem) in the queue at the same time so the queue player can properly advanced to the next item by itself. There will be a short flash in between but I found that acceptable and easily fixable by setting the background of the parent view to be a screenshot of the first frame of the video. – Mr. T Jun 10 '14 at 19:03

2 Answers2

8

Steve, the short answer is that you are not going to be able to get the kind of results you want using AVPlayer. The h.264 video logic included in iOS is really great at playing video and video/audio together, but it really sucks at starting/stopping and switching from one clip to another. The reason is that there is a lot of buffering that needs to happen to load up and start playing a h.264 video in hardware. Basically, you need to roll your own code that sets UIImage/CGImageRef for your views in a way that makes it easy to switch from one clip to another by simply switching from one array of UIImage objects to another. Of course, that is easy to say yet not so easy to implement.

What I would suggest is that you evaluate existing code that already implements this logic instead of rolling your own. For example, have a look at this StreetFighter demo app. It shows how a very simple game like iPhone UI can be constructed using a series of clips that show a character doing a kick, a punch, or throwing a fireball. The results looks like this:

enter image description here

I also wrote up a blog post about seamless-video-looping-on-ios. You can of course roll your own code to do all this, but I would suggest reading more about my library at the linked website as it will save you a lot of time.

MoDJ
  • 4,309
  • 2
  • 30
  • 65
  • Dead links - think I found your old blogpost on the topic https://iosgraphicsanimation.wordpress.com/2013/06/19/seamless-video-looping-on-ios/, but all the links from that page also point to the same un-reachable website – 10623169 Sep 15 '20 at 08:28
0

After the first video has played every frame except the last one, you quickly swap to a view with an image of the last frame (basically the last frame) and then you transition into a view with the an image of the first frame of the next video and start up that one.

Or you could create a animation with all your frames (programming your videos), that will make it customizable, but the quality will probably not be as good and the cpu usage can spike, so you will have to make a call on that one.