60 FPS playback of 240 screen-sized images?

I can’t share the original code for the bug I found because I plan to monetize it, but I managed to recreate it. Basically, my problem is the title - I’m trying to pre-render a bunch of frames (the original uses a laggy shader) and store them in a table or using saveImage(). Then I want to call startRecording() and loop through all the frames, so it’s at 60 FPS and won’t lag. But, it crashes.


--# Main
-- Playback Example

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    frames = {}
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)

    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here
    local img = image(WIDTH, HEIGHT)
    setContext(img)
    background(255)
    fill(255, 0, 0)
    noStroke()
    ellipse((#frames + 1) / 240 * WIDTH, HEIGHT / 2, 50)
    setContext()
    frames[#frames + 1] = img
    sprite(frames[#frames], WIDTH / 2, HEIGHT / 2)
end


That’s showing what happens if you put them in a table. If you use saveImage (I didn’t because I don’t want to clutter up your Documents), it doesn’t, but it crashes when attempting to loop through them.

Is it just not possible to store so many frames? Do the frames take up too much space or memory? Is the file IO just not quick enough for readImage() or sprite()? I need some help here, I don’t want to have to stitch them together into a movie on my Mac.

Also, stitching them together on my Mac isn’t quite working, because Dropbox seems to stop syncing the images once it gets near frame 200…

If your goal is solely to make a movie, then I really would recommend making it on your Mac. It’s what I’ve done for my last two Codea-based movies. I didn’t use Dropbox for getting the images off, though, I use libimobiledevice for a direct USB connection. But I had no difficulty in doing it.

@SkyTheCoder - I would suggest doing more experiments. The key is to isolate the problem.
It does sound like a memory issue.

You have started well by creating the simplest example that reproduces the problem. Now I would try things like

  • smaller images - is there a size at which it works?
  • whether the crash is related to the number of images, ie does it always crash at about it he same place?
  • estimating total memory use of the images, and researching whether there are limits on iOS apps

If you are having trouble syncing images to your Mac, you can easily transfer the images by connecting your iPad to it with iTunes. But that is manual, of course.

@SkyTheCoder - another option is to play the frames back on the iPad but not use the built in movie recorder. Instead, use a Mac app like Reflector to mirror the iPad screen and record on the Mac itself. That might reduce the strain on the iPad.

Or you could use iRec from the Emu4iOS store. You can record your screen using the iPad.

I’ll try testing what works, but for the two most recent replies: my problem is not recording the animation, it’s just putting the images on the screen. And I can’t do it live because I have a very complex shader which requires so many iterations for it to look nice (3m for 4s at 60 FPS), it would just be a very slow slideshow.

Here’s what the effect I’m processing looks like (this is a live version, the render has more iterations so it’s smoother), so you know how I can’t do it live:

screenshot

Obvious question - it doesn’t look as though you are using the whole screen, can you not reduce the size?

@Ignatz I am using the whole screen, what do you mean?

And no, I would prefer it be in 720p minimum. It was going to be a logo animation generator.