<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:Fixedsys;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
        {mso-style-priority:99;
        mso-style-link:"E-mail Signature Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.E-mailSignatureChar
        {mso-style-name:"E-mail Signature Char";
        mso-style-priority:99;
        mso-style-link:"E-mail Signature";
        font-family:"Times New Roman","serif";}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='color:#1F497D'>Thanks Brian,<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>I’ve switched to using
already-existing vtkimagedata objects from my application (medical images)
instead of taking a snapshot of the render window they’re in for each frame.
Now I’ve got a working mpeg file, turns out I didn’t really understand the
mpegwriter, and wasn’t doing any color-mapping of my input data. ANYway, capturing
the entire render window is next.<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Another question though, is
there a way to specify the length (and inherently the timing) of the movie?
Thanks!<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Beau<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #91C0FF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>From:</span></b><span
style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'> Wylie, Brian
[mailto:bnwylie@sandia.gov] <br>
<b>Sent:</b> Monday, July 31, 2006 1:43 PM<br>
<b>To:</b> Beau Sapach; vtkusers@vtk.org<br>
<b>Subject:</b> RE: [vtkusers] vtkMPEG2Writer<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:blue'>In this case, unlike many others, the error messages are actually
giving you good information. :)</span><span style='font-size:12.0pt;font-family:
"Times New Roman","serif"'><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:blue'>The mpeg encoders have to have multiples of 2 or multiple of 4 in
the image size of the movies it generates.</span><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:blue'>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. :)</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
<div>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<p><span style='font-size:10.0pt;font-family:"Fixedsys","serif"'> Brian
Wylie - Org 1424<br>
Sandia National Laboratories<br>
MS 0822 - Building 880/A1-J<br>
(505)844-2238
FAX(505)845-0833 <br>
____
_ __<br>
/ __ \____ _________ | | / (_)__
_ __<br>
/ /_/ / __ `/ ___/ __ `/ | / / / _ \ | /| / /<br>
/ ____/ /_/ / / / /_/ /| |/ / / __/ |/ |/ /<br>
/_/ \__,_/_/ \__,_/
|___/_/\___/|__/|__/ <br>
Unleash the Beast</span><o:p></o:p></p>
<div>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>
</div>
<blockquote style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt;
margin-left:3.75pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p>
<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'>
<hr size=2 width="100%" align=center>
</span></div>
<p class=MsoNormal style='margin-bottom:12.0pt'><b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> vtkusers-bounces+bnwylie=sandia.gov@vtk.org
[mailto:vtkusers-bounces+bnwylie=sandia.gov@vtk.org] <b>On Behalf Of </b>Beau
Sapach<br>
<b>Sent:</b> Monday, July 31, 2006 1:37 PM<br>
<b>To:</b> vtkusers@vtk.org<br>
<b>Subject:</b> [vtkusers] vtkMPEG2Writer</span><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><o:p></o:p></span></p>
<p class=MsoNormal>Hello everyone,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I’m trying to use vtkMPEG2Writer to capture the frames of a
render window into a movie but I keep getting these errors:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line
61<o:p></o:p></p>
<p class=MsoNormal>horizontal_size must be a even [4:2:0/4:2:2]<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line
61<o:p></o:p></p>
<p class=MsoNormal>vertical_size must be a even [4:2:0]<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line
61<o:p></o:p></p>
<p class=MsoNormal>vertical _size must be a even [field pictures]<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Generic Warning: In \vtk-5.0.0\Io\vtkMPEG2Writer.cxx, line
61<o:p></o:p></p>
<p class=MsoNormal>vertical _size must be a multiple of 4 [4:2:0 field
pictures]<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>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.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span style='font-family:"Courier New"'>void
Recorder::GrabFrame()<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-family:"Courier New"'>{<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
vtkImageData * frame = vtkImageData::New();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
vtkUnsignedCharArray * pData = vtkUnsignedCharArray::New();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
vtkRenderWindow * rw = GetRenderWindow();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
int * dim = rw->GetSize();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
rw->GetRGBACharPixelData(1,1,dim[0]-1,dim[1]-1,1,pData);<span
style='color:green'><o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
frame->SetExtent(0,dim[0],0,dim[1],0,0);<span style='color:blue'><o:p></o:p></span></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
frame->SetScalarTypeToUnsignedChar();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
frame->SetNumberOfScalarComponents(4);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
frame->GetPointData()->SetScalars(pData);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>void
Recorder::WriteFrame()<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>{
<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
vtkMPEG2Writer * mWriter = vtkMPEG2Writer::New();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
if(!started){<br>
mWriter->SetFileName(“d:\\testvideo.mpg”);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
mWriter->SetInput(frame);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
mWriter->Start();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
started = TRUE;<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
}else{<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
mWriter->SetInput(frame);<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
mWriter->Write();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>void
Recorder::StopRecording()<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>
mWriter->End();<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoAutoSig>--<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p></o:p></span></p>
<p class=MsoAutoSig><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Network
Administrator<o:p></o:p></span></p>
<p class=MsoAutoSig><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>In-Vivo
NMR Centre<o:p></o:p></span></p>
<p class=MsoAutoSig><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>University
of Alberta<o:p></o:p></span></p>
<p class=MsoAutoSig><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Phone:
(780) 492-8098<o:p></o:p></span></p>
<p class=MsoNormal><o:p> </o:p></p>
</blockquote>
</div>
</body>
</html>