Hey Beau,<br><br>Thank you so much! You are right! I update the pointer to the <font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">vtkWindowToImageFilter every time when I call the image rendering function. After I added 
</span></font><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">avi-&gt;SetInputConnection(w2i-&gt;GetOutputPort()) to the loop, the generated movie looks normal.<br>
<br>Also, off-screen rendering is acceptable. That is, when I set the off-screen rendering on, the program can still get proper movies. <br><br>Janny<br></span></font><br><div><span class="gmail_quote">On 5/30/07, <b class="gmail_sendername">
Beau Sapach</b> &lt;<a href="mailto:beau.sapach@ualberta.ca">beau.sapach@ualberta.ca</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">










<div link="blue" vlink="blue" lang="EN-US">

<div>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Hi Janny,</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">I'm not sure I understand your code…
the ImgRender() function somehow changes your input data and renders the image
(changing what is displayed in the window) and then returns a pointer to the
vtkWindowToImageFilter, correct?&nbsp; I'm not sure why you have w2i =
ImgRender() in your loop.&nbsp; Once you have a pointer to the filter you
shouldn't need to assign that pointer again, unless you're deleting
and re-creating the vtkWindowToImageFilter on each call to ImgRender(), are
you?&nbsp; If you are, then you should call avi-&gt;SetInputConnection(w2i-&gt;GetOutputPort())
each time you get a new w2i pointer.</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Beau</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<div>

<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr align="center" size="2" width="100%">

</span></font></div>

<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Janny Dong
[mailto:<a href="mailto:janny.dong@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">janny.dong@gmail.com</a>] <br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 29, 2007 3:16
PM<br>
<b><span style="font-weight: bold;">To:</span></b> Beau Sapach<div><span class="e" id="q_112dd935447b1b55_1"><br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] How to
write AVI files properly, Please Help</span></div></span></font></p>

</div><div><span class="e" id="q_112dd935447b1b55_3">

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Hey Beau,<br>
<br>
Thanks a lot for your suggestions. I still could not get correct movies. What I
did is:<br>
<br>
Define a function - static vtkWindowToImageFilter *ImgRender() to render the
images and pass WindowToImageFilter as a parameter to main(); <br>
My main function is<br>
int main( int argc, char *argv[] )<br>
{<br>
&nbsp;&nbsp;&nbsp; int imageN;<br>
&nbsp;&nbsp;&nbsp; //Generate avi file<br>
&nbsp;&nbsp;&nbsp; vtkWindowToImageFilter *w2i = ImgRender();<br>
&nbsp;&nbsp;&nbsp; vtkAVIWriter *avi = vtkAVIWriter::New();<br>
&nbsp;&nbsp;&nbsp; avi-&gt;SetInputConnection(w2i-&gt;GetOutputPort()); <br>
&nbsp;&nbsp;&nbsp; avi-&gt;SetFileName(&quot;test.avi&quot;);<br>
&nbsp;&nbsp;&nbsp; avi-&gt;Start();<br>
&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; for (imageN = 0; imageN &lt; 10; imageN ++)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; w2i = ImgRender();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; avi-&gt;Write();&nbsp; <br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; avi-&gt;End(); <br>
&nbsp;&nbsp;&nbsp; avi-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; w2i-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; return 0;<br>
}<br>
<br>
I don&#39;t know how you set up your loop to generate movies. I already switched to
on-screen rendering and I could see the images in the rendering window were
changing. I am guessing probably it&#39;s not a good way to pass the
WindowToImageFilter as a parameter, but I have no better idea to do this right
now, because my image rendering part is fairly large, and I try to make the
code neat by defining the rendering part as a function and calling it in the
main function. <br>
<br>
Sorry to bother you and thanks for sharing your experience with me.<br>
<br>
Janny</span></font></p>

<div>

<p><span><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On 5/29/07, <b><span style="font-weight: bold;">Beau
Sapach</span></b> &lt;<a href="mailto:beau.sapach@ualberta.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
beau.sapach@ualberta.ca</a>&gt; wrote:</span></font></span></p>

<div link="blue" vlink="blue">

<div>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Hi Janny,</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">My movies are 2-4MB or less for 30 frames @ 25 frames per
second.&nbsp; I just realized something though.&nbsp; If you&#39;re using
SetOffScreenRendering(1) then when you call Render() the image in the window is
not updated.&nbsp; It&#39;s the image in the vtkRenderWindow that the
vtkWindowToImageFilter uses.&nbsp; I&#39;m just guessing but the single static
image you&#39;re seeing in the AVI file is probably the last image that was
rendered to the window (before off-screen rendering was switched on).</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">It may work properly if you leave rendering on-screen.
&nbsp;Or if you want to use off-screen rendering you could probably get the
memory buffer that the vtkRenderWindow it&#39;s rendering to, and use the RGBA data
in there to build your own vtkImageData object and write that to the AVI.</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<div>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Beau</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr align="center" size="2" width="100%">

</span></font></div>

<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> Janny Dong [mailto:
<a href="mailto:janny.dong@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">janny.dong@gmail.com</a>] <br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 29, 2007 12:27
PM<br>
<b><span style="font-weight: bold;">To:</span></b> Beau Sapach<br>
<b><span style="font-weight: bold;">Cc:</span></b> vtkusers<br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] How to
write AVI files properly, Please Help</span></font></p>

</div>

<div><span>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Beau, you said you didn&#39;t have size problem. You are
saying your movie is reasonably smaller? <br>
<br>
I added Modified() before the line WindowToImage-&gt;update() as you suggested.
The movie still shows a single static image. :( <br>
<br>
Janny</span></font></p>

<div>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On
5/29/07, <b><span style="font-weight: bold;">Janny Dong</span></b> &lt;<a href="mailto:janny.dong@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">janny.dong@gmail.com</a>&gt;
wrote:</span></font></p>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">Thanks,
Beau. I tried to play with FFMPEG, but with no success. I am using MSVC, and
unfortunately FFMPEG doesn&#39;t support it, so I couldn&#39;t get the library
installed. My project requires automated movie generation. That&#39;s why I am
struggling to get everything under control in my code. :( <br>
<br>
Janny</span></font></p>

<div>

<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

<div>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">On
5/29/07, <b><span style="font-weight: bold;">Beau Sapach</span></b> &lt;<a href="mailto:beau.sapach@ualberta.ca" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> beau.sapach@ualberta.ca</a>&gt;
wrote:</span></font></p>

<div link="blue" vlink="purple">

<div>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">I think I had a similar problem, not the size issue but the
single, static image issue.&nbsp; Try calling Modified() on
vtkWindowToImageFilter before you call Update().&nbsp; As for frame rate I
don&#39;t know how to set that with vtk&#39;s classes, I suggest you look at FFMPEG, it
can be built into VTK but I&#39;ve had little luck doing so.&nbsp; Currently I
write out image files and have my application call the ffmpeg executable to
encode the images as a movie, using ffmpeg command line options you can control
framerate.</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Beau</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">&nbsp;</span></font></p>

<div>

<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr align="center" size="2" width="100%">

</span></font></div>

<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;"> vtkusers-bounces+beau.sapach= 
<a href="mailto:ualberta.ca@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">ualberta.ca@vtk.org</a>
[mailto:<a href="mailto:vtkusers-bounces+beau.sapach=ualberta.ca@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vtkusers-bounces+beau.sapach=ualberta.ca@vtk.org</a>] <b><span style="font-weight: bold;">
On Behalf Of </span></b>Janny Dong<br>
<b><span style="font-weight: bold;">Sent:</span></b> Tuesday, May 29, 2007 8:24
AM<br>
<b><span style="font-weight: bold;">To:</span></b> vtkusers<br>
<b><span style="font-weight: bold;">Subject:</span></b> [vtkusers] How to write
AVI files properly, Please Help</span></font></p>

</div>

<div>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">I posted a similar question but didn&#39;t get any answer,
probably I didn&#39;t make it clear enough.<br>
<br>
I am coding a C++ program to visualize my data and generate movie
automatically. I put vtkAVIWriter in a loop to get a movie out of the
rendering. It did get an avi file, but not the one I expected. I have two
questions about it. <br>
<br>
(1) The size of the movie file is 18MB, but it has only 50 frames. Moreover, it
is only 3 second long. Can I compress the movie file with vtkAVIWriter? How can
I control the speed of the movie, like specifying number of frames per second? <br>
<br>
(2) I found the avi file displayed only one frame like a static image. However,
I did update the data when rendering each frame. The data rendering part in my
program is like<br>
data
points---&gt;vtkPolyData---&gt;vtkDelaunay2D---&gt;vktPolyDataMapper---&gt;vtkRenderer---&gt;vtkWin32OpenGLRenderWindow-&gt;SetOffScreenRendering(1)---&gt;vtkWindowToImageFilter---&gt;vtkAVIWriter
<br>
<br>
I have something like: PolyDataMapper-&gt;update(); WindowToImage-&gt;update()
in my code.&nbsp; Did I call update() in a wrong way or should I call it in
different parts of the code?<br>
<br>
Any suggestions will be greatly appreciated. <br>
<br>
Janny<br>
&nbsp;</span></font></p>

</div>

</div>

</div>

</div>

<p style="margin-bottom: 12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

</div>

</div>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

</span></div>

</div>

</div>

</div>



<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">&nbsp;</span></font></p>

</span></div></div>

</div>


</blockquote></div><br>