new iPhone video player for OF development

I had some bad time dealing with ofxiphoneVideoPlayer as it didn’t work on ios5 and it had several performance problems and visual bugs.

At the end I decided to reimplement the video player from scratch.
I found out that inserting the video player view into the UIwindow view gave a much better performance.

For the project that I needed to use this is OK but I want to implement to replace ofxiphonevideoplayer, but I’m not sure about which implementation model to use.

One waywould be to have it working in the same way as the any OF video player so the code compatibility doesn’t get corrupted, but this means a lot of pixel copying and textures passing from one place to another, hence a performance gets degraded.

The other way is to use the method that I used in the project for which I implemented this new video player.
This is esentially to use ios AVPlayer class and it’s implementation in ObjC as sujested by apple with a C++ wrapper so it’s controlable and instantiable from OF.
Everything can be done to work in the same way as OF’s video players, exept for the drawing part.
I just used another UIview subclass that I inserted into the app UIWindow, below OF’s glview.
This yields a much better performance because there’s no extra pixel copying from the video player to the glview, but the video can only be rendered at the end or the begining of OF’s draw(). (actually is either on top or bellow OF’s glview).

So which route should I take?

I’ll upload soon some examples of this working.

cheers

One waywould be to have it working in the same way as the any OF video player so the code compatibility doesn’t get corrupted, but this means a lot of pixel copying and textures passing from one place to another, hence a performance gets degraded.

Can you give an example of how degraded it is? It feels like multiple GL views is a little counter to how things intuitively should work in OF, but iPhone is a weird case where OF is already doing tons of stuff that iOS dev doesn’t seem to jive too well with anyways so I’m not sure that it’s that much of a problem.

Hi Josh,
I can take same videos of the same thing running with the different options.
I’ll post the code also, but right now I’m quite busy to do so.

hey roy,

if you have your video in another UIView then it can only sit below or above what OF draws. it can’t be drawn somewhere in the middle of the OF draw method. you will need to have the video as a texture if you want to do this.

playing a video using the native video player is good when you want it to take over the screen over your OF app.
this is the way im doing it for a project im currently working on. happy to share the code with you if you are still stuck.

L.

The more I think about, and admitedly I haven’t thought about it a ton since I don’t have an iPhone, it really doesn’t makes sense have multiple GL views of any kind, unless the programmer explicitly wants those, because to leave it w/multiple views invites all kinds of confusion and messiness later on. I know it’s a performance hit, so maybe we could have a some kind of flag to pass to ofVideoPlayer just in the iPhone implementation? Or just two videoPlayer types included in core: that shares textures, etc like normal in OF and is a little slower, and one that doesn’t and is faster, ofVideoPlayerIos (?)

@julapy,
I already finished the project for which I implemented this.ç
Yeah, I now what you mention about having the UIView either over o below but not in the middle.
What I wanted was to avoid pixel copying to have a gl texture.
Although you can have set your glview to use a transparent background so you can draw thing over the videos.
Yet for this to work I had to go through all the ofxiPhone implementation because it’s method to set the glview to have a transparent background didn’t work.
The fix is easy,
change in addons/ofxiPhone/src/ofxiPhoneExtras.mm to the following:

  
  
 void ofxiPhoneSetGLViewTransparent(bool b) {  
  //ofxiPhoneGetGLView().opaque = !b;//this doesn't work  
  ofxiPhoneGetGLView().layer.opaque = !b;//this one does.  
 }  
  

@ joshua,
In fact there aren’t 2 glviews, one is a UIView and the other a EAGLview (probably the UIView is also some sort of openGL subclass but I can’t really tell for sure). The iOS AVPlayer class renders the video natively into the UIView but to use this as a texture within the glview some sort of screen grabbing and pixel copying must be done.
I guess that the approach that you suggest could be really helpful.
I’ll give it a try soon.

regards

Lukasz you using ofVideoPlayer or the video playing code in the iOS sdk? If the iOS sdk version, could you possibly share some code on how this works?

Many thanks!

@chris, I have some working code in my github.
https://github.com/roymacdonald/ofxAVFoundationPlayerTest

the avFoundation player is drawn below OF’s glview, so you can still draw things over the video with of
OF.
good luck