[vtkusers] Python VTK, how to record a video?

Maksim Surov surov.m.o at gmail.com
Tue Jun 16 06:26:02 EDT 2015


Hello.

I am trying to record a video of VTK 3D animation in Python. The example I
found  <http://www.itk.org/Wiki/VTK/Examples/Cxx/Video/FFMPEG> is a bit
strange for me, because it does not create a render, so it is not clear how
to attach actors to canvas.

I write a simplified example:

import vtk
# draw a planeplane_source =
vtk.vtkPlaneSource()plane_source.SetCenter(0, 0,
0)plane_source.SetNormal(0, 0, 1)plane_mapper =
vtk.vtkPolyDataMapper()plane_mapper.SetInput(plane_source.GetOutput())plane_actor
= vtk.vtkActor()plane_actor.SetMapper(plane_mapper)
# create renderrender = vtk.vtkRenderer()renWin =
vtk.vtkRenderWindow()renWin.AddRenderer(render)renWin.SetSize(800,
600)renInter = vtk.vtkRenderWindowInteractor()renInter.SetRenderWindow(renWin)render.AddActor(plane_actor)renWin.Render()renInter.Initialize()
# set callbackdef cb(interactor, event):
    global plane_actor
    plane_actor.RotateZ(0.1)
    interactor.GetRenderWindow().Render()
renInter.AddObserver('TimerEvent', cb)timerId =
renInter.CreateRepeatingTimer(100);
# put something here?writer = vtk.vtkFFMPEGWriter()# ???
writer.SetInputConnection(...)writer.SetFileName("test.avi")writer.Start()
# runrenInter.Start()

My question is *how to connect vtkRenderer to vtkFFMPEGWriter*?


-- 
*Best regards, *
*Maksim Surov*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150616/1e56b21d/attachment.html>


More information about the vtkusers mailing list