Search code examples
pythonanimationparaview

Save Animation via Python Script in ParaView


I am trying to save an .avi animation in ParaView via python script. The script I wrote works, nonetheless, the animation corresponds to a steady frame. What should I change in order to obtain an animation with all 10 frames from my ParaView model?

Here is my script (movie.py):

from paraview.simple import *
movie = servermanager.animation.AnimationScene()
movie.ViewModules = [GetActiveView()]
movie.NumberOfFrames = 10
movie_writer = servermanager.vtkSMAnimationSceneImageWriter()
movie_writer.SetFileName("/Users/wbr/Desktop/movie.avi")
movie_writer.SetFrameRate(1)
movie_writer.SetQuality(2)
movie_writer.SetAnimationScene(movie.SMProxy)
movie_writer.Save()

Solution

  • With ParaView 4.2 (RC1), this is the script I get when I generate a Python trace for the action of saving an animation.

    #### import the simple module from the paraview
    from paraview.simple import *
    
    # save animation images/movie
    WriteAnimation('/tmp/movie.ogv', Magnification=1, FrameRate=15.0, Compression=True)