[vtkusers] Re: how to output an avi file in VTK

Goodwin Lawlor goodwin.lawlor at ucd.ie
Mon May 29 05:34:29 EDT 2006


Wang HJ wrote:
> Hi everybody
> 
> I have a program to render images in a loop (so it looks like an 
> animation) in vtk, now I want to save those results in an avi file, I 
> knew I could use the class vtkAVIWriter, but I do not know how to use 
> it, I wrote my code like:
> vtkAVIWriter *w=vtkAVIWriter::New();
> w->SetFileName("c:/TestAVIWriter.avi");
> w->Start();
>  for (i = 0; i < 9; ++i)
>    {
>    // Render the image and rotate the active camera by one degree
>    renWin->Render();
>  // aRenderer->GetActiveCamera()->Azimuth(10);
>   aRenderer->GetActiveCamera()->Elevation(-10);
>   aRenderer2->GetActiveCamera()->Elevation(10);
>   w->Write();
>   }
>   w->End();
> ......
> 
> but it did not write "*.avi" file at all.
> 
> it gave me this message:
> ERROR: In .\vtkAVIWriter.cxx, line 74
> vtkAVIWriter (025F39E8): Write:Please specify an input!
> 
> how can I connect the specify input  . Thanks in advance
> 

Hi HJ,

Try:

vtkWindowToImage *w2i = vtkWindowToImage::New();
   w2i->SetInput(renWin);

vtkAVIWriter *w=vtkAVIWriter::New();
   w->SetFileName("c:/TestAVIWriter.avi");
   w->SetInputConnection(w2i->GetOutputPort());
   w->Start();

  for (i = 0; i < 9; ++i)
    {
    // Render the image and rotate the active camera by one degree
    aRenderer->GetActiveCamera()->Azimuth(10);
    aRenderer->GetActiveCamera()->Elevation(-10);
    aRenderer2->GetActiveCamera()->Elevation(10);
    renWin->Render();
    w2i->Modified();
    w->Write();
    }

   w->End();


hth

Goodwin




More information about the vtkusers mailing list