about export video using vtkAVIWriter
hi,every body.recently i want to use vtk to export video.i use the vtkAVIWriter.i looked for some code from internet.the code is as followed:
/*
vtk version:8.2
*/
static int frameCount = 0;
void ExecuteTimerCallback(vtkObject* caller, unsigned long eventId, void* clientData, void* callData)
{
vtkRenderWindowInteractor* iren = static_cast<vtkRenderWindowInteractor*>(caller);
VideoSaveTool* pSaveTool = static_cast<VideoSaveTool*>(clientData);
if (frameCount < 200)
{
iren->Render();
pSaveTool->mScreenshotFilter->Modified();
pSaveTool->mScreenshotFilter->Update();
pSaveTool->mAviWriter->Write(); // the crash place.
frameCount++;
}
else
{
iren->DestroyTimer();
}
}
void VideoSaveTool::saveVideo()
{
vtkRenderer* ren = mThreeDWindow->getRenderer();
mThreeDWindow->getStyle()->GetInteractor()->Initialize();
vtkNew<vtkCallbackCommand> callback;
callback->SetCallback(ExecuteTimerCallback);
callback->SetClientData(this);
mThreeDWindow->getStyle()->GetInteractor()->AddObserver(vtkCommand::TimerEvent, callback);
mScreenshotFilter = vtkSmartPointer<vtkRenderLargeImage>::New();
mScreenshotFilter->SetInput(ren);
mScreenshotFilter->SetMagnification(1.0);
mScreenshotFilter->Update();
mAviWriter = vtkSmartPointer<vtkAVIWriter>::New();
mAviWriter->SetFileName("D:/output.avi");
mAviWriter->SetInputData(mScreenshotFilter->GetOutput());
mAviWriter->SetQuality(2);
mAviWriter->SetRate(24);
mAviWriter->SetCompressorFourCC("DIB");
mAviWriter->Start();
mThreeDWindow->getStyle()->GetInteractor()->CreateRepeatingTimer(10);
mThreeDWindow->getStyle()->GetInteractor()->Start();
mAviWriter->End();
}
then i found that that then the demo crashed at the pSaveTool->mAviWriter->Write() in the callback function ExecuteTimerCallback. the call stack show that there is something wrong in the Avifil32.dll.. help!
Edited by xiaojing guo