martedì 31 maggio 2011

How to make MPEG movies from single images

Generally it is not straightforward to make an MPEG movie inside Python or IDL from a sequence of plots.
To overcome this problem we can save all the images we need in the movie in a separate folder and then run the following command:

mencoder 'mf://*.png' -mf type=png:fps=7 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o movie.mpg

All the images *.png will be added in the MPEG movie.mpg

This is an IDL example to write jpeg images in a loop:

for t=0,Tot do begin
  tvframe, matrix(*,*,t), /bar, brange=[-200,200], /asp,btitle='v [m/s]', yr=[0.,200*0.17]
  image=tvrd(TRUE=3)
  WRITE_JPEG, '~/temp/'+'im'+strtrim(t)+'.jpg', image , true=3
endfor 

1 commento: