[vtkusers] Problems using more than one vtkMPEG2Writer simultaneously, only one creates a working MPEG
Jefferson Thomas
foramuyou at gmail.com
Wed May 28 05:13:09 EDT 2008
Hi,
I want to use more then one vtkMPEG2Writer in the same time and output
many MPEG.
The problem is that every time I try to do it only one of the MPEG
files is working after that.
Here is a mininal code :
#include "vtkMPEG2Writer.h"
#include "vtkWindowToImageFilter.h"
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
int main(void) {
vtkCylinderSource *cylinder = vtkCylinderSource::New();
cylinder->SetResolution(8);
vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
vtkActor *cylinderActor = vtkActor::New();
cylinderActor->SetMapper(cylinderMapper);
cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
cylinderActor->RotateX(30.0);
cylinderActor->RotateY(-45.0);
vtkRenderer *renderer = vtkRenderer::New();
renderer->AddActor(cylinderActor);
vtkRenderWindow *window = vtkRenderWindow::New();
window->AddRenderer(renderer);
vtkWindowToImageFilter* w2if =vtkWindowToImageFilter::New();
w2if->SetInput(window);
vtkMPEG2Writer *moviewriter1 = vtkMPEG2Writer::New();
moviewriter1->SetFileName("test1.mpg");
moviewriter1->SetInputConnection(w2if->GetOutputPort());
moviewriter1->Start();
vtkMPEG2Writer *moviewriter2 = vtkMPEG2Writer::New();
moviewriter2->SetFileName("test2.mpg");
moviewriter2->SetInputConnection(w2if->GetOutputPort());
moviewriter2->Start();
window->Render();
w2if->Modified();
moviewriter1->Write();
moviewriter2->Write();
moviewriter1->End();
moviewriter2->End();
}
Linking with : -lvtkRendering -lvtkjpeg -lvtkexpat -lvtkftgl
-lvtkfreetype -lGL -lGLw -lOSMesa -lpthread -ldl -lm -lvtkDICOMParser
-lvtkpng -lvtktiff -lvtkzlib -lvtkGraphics -lvtkImaging -lvtkIO
-lvtkFiltering -lvtkCommon -lvtksys -lvtkMPEG2Encode
The output will be two mpeg files "test1.mpg" and "test2.mpg". But
only "test1.mpg" can be displayed ! What is strange is that they have
the same size and almost the same content. Only few bytes differ...
How can it be done properly, so that all the mpgs work after creation ?
Thomas
More information about the vtkusers
mailing list