[vtkusers] vtkMPEG2Writer
Wylie, Brian
bnwylie at sandia.gov
Mon Jul 31 15:43:24 EDT 2006
In this case, unlike many others, the error messages are actually giving
you good information. :)
The mpeg encoders have to have multiples of 2 or multiple of 4 in the
image size of the movies it generates.
Grab the size of the render window with GetSize(), and then resize the
window (probably smaller) to the next multiple of 4 in both directions,
I'm assuming with SetSize(). Then it should work ok. :)
Brian Wylie - Org 1424
Sandia National Laboratories
MS 0822 - Building 880/A1-J
(505)844-2238 FAX(505)845-0833
____ _ __
/ __ \____ _________ | | / (_)__ _ __
/ /_/ / __ `/ ___/ __ `/ | / / / _ \ | /| / /
/ ____/ /_/ / / / /_/ /| |/ / / __/ |/ |/ /
/_/ \__,_/_/ \__,_/ |___/_/\___/|__/|__/
Unleash the Beast
________________________________
From: vtkusers-bounces+bnwylie=sandia.gov at vtk.org
[mailto:vtkusers-bounces+bnwylie=sandia.gov at vtk.org] On Behalf Of Beau
Sapach
Sent: Monday, July 31, 2006 1:37 PM
To: vtkusers at vtk.org
Subject: [vtkusers] vtkMPEG2Writer
Hello everyone,
I'm trying to use vtkMPEG2Writer to capture the frames of a
render window into a movie but I keep getting these errors:
Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line 61
horizontal_size must be a even [4:2:0/4:2:2]
Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line 61
vertical_size must be a even [4:2:0]
Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line 61
vertical _size must be a even [field pictures]
Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line 61
vertical _size must be a multiple of 4 [4:2:0 field pictures]
Here is the code behind my Recorder object. This is somewhat
simplified so I'm sure if it were compiled would cause some problems, I
can already see one memory leak. Nonetheless, if anyone sees any
obvious problems with this, please let me know! The functions are
called in the order they are presented.
void Recorder::GrabFrame()
{
vtkImageData * frame = vtkImageData::New();
vtkUnsignedCharArray * pData =
vtkUnsignedCharArray::New();
vtkRenderWindow * rw = GetRenderWindow();
int * dim = rw->GetSize();
rw->GetRGBACharPixelData(1,1,dim[0]-1,dim[1]-1,1,pData);
frame->SetExtent(0,dim[0],0,dim[1],0,0);
frame->SetScalarTypeToUnsignedChar();
frame->SetNumberOfScalarComponents(4);
frame->GetPointData()->SetScalars(pData);
}
void Recorder::WriteFrame()
{
vtkMPEG2Writer * mWriter = vtkMPEG2Writer::New();
if(!started){
mWriter->SetFileName("d:\\testvideo.mpg");
mWriter->SetInput(frame);
mWriter->Start();
started = TRUE;
}else{
mWriter->SetInput(frame);
mWriter->Write();
}
}
void Recorder::StopRecording()
{
mWriter->End();
}
--
Network Administrator
In-Vivo NMR Centre
University of Alberta
Phone: (780) 492-8098
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060731/f79c708f/attachment.htm>
More information about the vtkusers
mailing list