[vtkusers] Video output vtkOggTheoraWriter
Emma Saunders
emmasaunders123 at gmail.com
Wed Jun 24 10:38:54 EDT 2015
Hi All,
I am attempting to output video from a rendered moving sphere using
vtkOggTheoraWriter and windowToImageFilter. I can output a series of png
files but when attempting to write the video the quality is checkered, does
this have anything to do with the size, or frame rate? Any advice
appreciated, below is my code.
int main(int, char *[])
{
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetCenter(0.0, 0.0, 0.0);
sphereSource->SetRadius(5.0);
sphereSource->Update();
// Visualize
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(sphereSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
int *size1 = renderWindow->GetSize();
renderWindow->SetSize(size1[0]/2, size1[1]/2);
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(actor);
renderWindow->Render();
// Screenshot
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
vtkSmartPointer<vtkWindowToImageFilter>::New();
windowToImageFilter->SetInput(renderWindow);
windowToImageFilter->SetMagnification(1);
windowToImageFilter->SetInputBufferTypeToRGBA();
windowToImageFilter->ReadFrontBufferOff();
windowToImageFilter->Update();
vtkSmartPointer<vtkOggTheoraWriter> writer =
vtkSmartPointer<vtkOggTheoraWriter>::New();
writer->SetInputConnection(windowToImageFilter->GetOutputPort());
writer->SetFileName("output.mp4");
writer->Start();
int i;
char filenames[16];
for(i=0;i<10;i++)
{
actor->RotateY(5);
renderer->ResetCameraClippingRange();
renderWindow->Render();
windowToImageFilter->SetInput(renderWindow);
renderer->ResetCamera();
windowToImageFilter->Modified();
windowToImageFilter->Update();
writer->Write();
}
writer->End();
return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150624/adfd0b47/attachment.html>
More information about the vtkusers
mailing list