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 

How to keep a process running after SSH logout

After SSH logout all the processes running are terminated.
To keep a process running you can use the "screen" command as follows (command sequence in a linux terminal):

  1. ssh user@server (SSH login as usual)
  2. screen
  3. Now we can launch the command we want to keep alive
  4. Ctrl+a D (this command detach the current terminal and logout)
Now we can close the SSH connection and the process will keep running.

To resume the detached shell we can simply login using SSH and then run the command:
  • screen -r