let me share my latest experience with creating videos (I know some
people like Sameer are interested in that).
So here is the video done in visit:
http://www.youtube.com/watch?v=D0vqFHg2Fnk
watch the movie in HD quality (click on the "HD" button in the youtube
player). Notice the camera fly-by, I think this would be especially
cool in the flow simulations, where you want to watch some vertex or
turbulence or something for a while and then zoom out etc.
This was converted from a set of png files by:
ffmpeg -i frame%04d.png -r 15 -vcodec copy mhd.avi
Here is a script that uses VisIt to produce the png files:
-------------------
print "starting"
OpenDatabase("/netscratch/ondrej/vtk/frame*.vtk database")
AddPlot("Pseudocolor", "C")
p = PseudocolorAttributes()
p.min, p.minFlag = 0.174630617373, 1
p.max, p.maxFlag = 2.23176607373, 1
SetPlotOptions(p)
print "drawing"
DrawPlots()
v1 = View2DAttributes()
v1.windowCoords = (-2, 2, -2, 2)
v2 = View2DAttributes()
v2.windowCoords = (-1.05, -0.85, -0.10, 0.10)
cpts = [v1, v1, v2]
print cpts
x = [0., 0.5, 1.]
def animate():
print "animating"
s = SaveWindowAttributes()
s.format = s.PNG
s.fileName = "frame"
s.width, s.height = 1024,768
s.screenCapture = 0
SetSaveWindowAttributes(s)
nsteps = TimeSliderGetNStates()
for i in range(nsteps):
t = float(i) / float(nsteps - 1)
c = EvalCubicSpline(t, x, cpts)
SetTimeSliderState(i)
print c
SetView2D(c)
SaveWindow()
print "done"
animate()
-------------------
run it with:
visit -cli -s video_script.py
as you can see from the first line, it expects a set of VTK files in
the directory /netscratch/ondrej/vtk/frame*.vtk.
To produce those vtk files, I wrote this simple library:
http://certik.github.com/visit_writer/
and here is the script that takes the data from the simulation (in .h5
format) and uses the visit_writer library (above) to create the vtk
files:
http://github.com/certik/mhd/blob/9d5fcaa20067701222fba9443affa834ed8dd86f/plot.py
You can clone the whole git repository using:
git clone git://github.com/certik/mhd.git
it's just couple scripts. To create the .h5 file with the data, I
wrote this script:
http://github.com/certik/mhd/blob/9d5fcaa20067701222fba9443affa834ed8dd86f/readbin3.py
it produces python pickle files, that I then converted them to an h5
format using this older revision of plot.py:
http://github.com/certik/mhd/blob/d1184d35ca2b1f9e486f449a11285e45df3223f0/plot.py
So with hermes, I suggest to take the solution as a lin file (in C++),
or just the linearizer output in Python, then produce vtk files out of
it. And then use mayvi or visit for any kinds of nice animations. It's
very flexible, the vtk format contains all the data and you then tell
the visualizer how you want them to be visualized.
I'll probably write the exporters to vtk for my own fluid dynamics
stuff and post patches to hermes.
Ondrej
One thing is the video quality, e.g. I noticed when you converted the
bitmaps, you encoded the avi file using a low quality compression, so
it looks ugly sometimes. I don't know if my approach (ffmpeg -i
frame%04d.png -r 15 -vcodec copy mhd.avi) is the best, but it does
produces high quality videos.
As to the other things -- essentially we use hermes' opengl
visualisation, which is good enough for many purposes. But sometimes
as I said, I would like to fly by, e.g. zoom into some part, zoom out,
etc. For that, I would export to vtk and use some external program,
like visit, or mayavi.
It's on my todo to do it for my MHD simulations.
Ondrej
You are both using essentially the same thing to encode the video
(MPEG4). The quality can be controlled by the bitrate which can be set
on the command line. The better quality, the larger the resulting
video file.
Jakub
Yes, but unfortunately I totally failed to convince mencoder to
produce higher quality videos by forcing the bitrate. By using the
"-vcodec copy" trick above, it works for me.
Ondrej
I am using something like this (see man mplayer at the end)
-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=3200
and it works.
Jakub