Fast Screen Recording of iOS App
Asked Answered
B

1

0

I'm new to OpenGL ES. I'm trying to write code for screen recording of iOS apps, especially games.

I'm using the 'render to texture' method described with code in this answer to capture screen and write the video for a cocos2d game. One modification I made was that, when I call CVOpenGLESTextureCacheCreate then I'm using [EAGLContext currentContext] instead of

[[GPUImageOpenGLESContext sharedImageProcessingOpenGLESContext] context]

It does record the video but there are two issues

(1)- When it starts recording then new drawing on the screen stops. I want the app to keep on drawing on the screen too. As I'm new to OpenGL ES, I don't have deep understanding of frame buffer objects etc., so I have a hard time figuring out how to simultaneously draw on screen and capture the screen as well. I'll appreciate a code example in this regard.

(2)- The recorded video is flipped upside down. How can I get it in correct direction?

Previously I considered glReadPixels method too, but that has performance drawbacks.

Update: a couple of ideas also came to mind. According to my little understanding,

I could simply draw my texture back to screen, but don't know how.

OR

I could have a secondary FBO and I could attach the texture to it, i.e.

glGenFramebuffersOES(1, &textureFrameBuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, textureFrameBuffer);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, CVOpenGLESTextureGetName(renderTexture), 0);
//Then I restore the screen FBO.
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 1);

But if I do that, then how do I copy the screen-drawing to my secondary FBO?

Bastia answered 17/11, 2012 at 13:24 Comment(1)
Is your problem solved? I am still facing the same issue but instead of cocos2d I am using Sparrow framework?Aundrea
K
0

There are readymade solutions for this, so if you're not looking to re-invent the wheel, you can try out Everyplay (https://everyplay.com/about).

The documentation for recording the screen from the OpenGL level can be found here: https://developers.everyplay.com/doc/Everyplay-integration-to-iOS-game

Disclaimer: I work for the company that makes Everyplay

Kiowa answered 1/2, 2013 at 7:59 Comment(1)
Thanks TuomasR, however the nature of my app requires somewhat reinvention of this wheel. :), I'll highly appreciate if you could throw in a few lines of code or direct me on how to copy rendered image from one FBO to another. Many thanks.Bastia

© 2022 - 2024 — McMap. All rights reserved.