How to increase frame rate or execute my own codes in each frame waiting time in CubeExample?
Hi, Brad
I am concentrating on your CubeExample. In normal condition the frame rate is 30fps, and I found that each frame has to wait about 33.3 ms in callback method -(void)newFrameReadyFromTextureOutput:(GPUImageTextureOutput *)callbackTextureOutput;(I suppose 1000ms/30fps=33.3ms, right?) before execute the following render method:[self renderByRotatingAroundX:0.0 rotatingAroundY:0.0];
However, the problem is that I have some codes need to be executed after each callback method - (void)newFrameReadyFromTextureOutput:(GPUImageTextureOutput *)callbackTextureOutput;. After testing, the processing time of these codes is 20ms. So when I execute my codes, the frame rate will be decreased to about 19 fps(maybe because 1000ms/(20+33.3)=19fps). The problem is also mentioned in issue 1801.
First, I tried the '[videoCamera setFrameRate:60]' hoping to shorten the waiting time by ** increasing frame rate **. But I found the maximum frame rate can be set is 30 fps. If fps is set to value larger than 30, the program will crash. This problem is quite puzzle for me. My device is iPad air. So can I increase the frame rate to shorten the waiting time?
Second, is there any solutions to help me execute my own processing codes while each frame waits(that is the 33.3ms)? Then I don’t need to increase frame rate to keep the video fluency.
Can you give me some idea ?
The current version of that example couples rendering to getting new frames from the camera. As those frames come in, it triggers rendering downstream.
The iOS camera by default tops out at 30 FPS or so, dropping as needed due to reduced illumination.
The rendering loop doesn't need to be solely driven by the input framerate. You can have an independent rendering loop within your custom OpenGL processing that merely reads from the input texture as needed. You may need to sync up input texture updates with completed processed frames, but you could have your render loop run at 60 FPS if you wanted, then output the result of that to the view.