save videos with a loop



  • Hi! I’m trying to save multiple mp4s with a loop, but each next video contains all the previous + the current one. Sort of like 0, 0+1, 0+1+2, etc.

    Could you please help, I’m probably missing something obvious? Should I reset the saveImage somehow?

    Here’s a test code:

    W, H = 500, 500
    FRAMES = 5
    fps = 5
    
    outputs = 3
    for output in range(outputs):
        
        for frame in range(FRAMES):
            newPage(W, H)
            frameDuration(1/fps)
            fill(1/(output+1))
            rect(0, 0, W, H)
        
        saveImage("~/Desktop/test-%s.mp4" % output)
    
    

    Thank you!


  • admin

    you will need to reset the drawing stack with newDrawing() after you exported a video

    see https://www.drawbot.com/content/canvas/pages.html#drawBot.newDrawing

    W, H = 500, 500
    FRAMES = 5
    fps = 5
    
    outputs = 3
    for output in range(outputs):
        
        newDrawing()
    
        for frame in range(FRAMES):
            newPage(W, H)
            frameDuration(1/fps)
            fill(1/(output+1))
            rect(0, 0, W, H)
        
        saveImage("~/Desktop/test-%s.mp4" % output)
    


  • Thank you!


Log in to reply