Monday, January 18, 2010

Satellital weather videos II

Continuing with the topic from last post, let's see how to convert the .tif files found in http://goes.gsfc.nasa.gov/goeseast-lzw/argentina/vis/  (visible light). Download them:


wget --limit-rate=100k -e robots=off -U "Mozilla/5.0 (compatible; Konqueror/3.2; Linux)" -np -l1 -r -A .tif -N http://goes.gsfc.nasa.gov/goeseast-lzw/argentina/vis/
Convert them to  .jpg:
convert -limit memory 1 -limit map 1 goes.gsfc.nasa.gov/goeseast-lzw/argentina/vis/*.tif goes.gsfc.nasa.gov/goeseast-lzw/argentina/vis/img_%03d.jpg

(Note: change %03d to %04d if you want 4 leading zeroes in your filename, for example if you have more than 1000 pictures to convert, so all files end sorted sequentially) .

And now we convert the pics to video just like before:

mencoder "mf://goes.gsfc.nasa.gov/goeseast-lzw/argentina/vis/*.jpg" -mf fps=8 -o output_vis.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000 -vf scale=640:384

Ready. We upload to youtube...



Hope you enjoy this and create your own weather videos!

Satellital weather videos

I always liked satellital weather videos, so hipnotic and fascinating. For some reason, when weather channels on the TV or weather websites publish such videos, they are very short, even 4 or 5 frames, leaving me hungry for more.

Luckily, there is http://goes.gsfc.nasa.gov where we can find satellital pictures from the last weeks showing different parts of the planet. We just need to download them and convert them to video.

This is how I did it using Ubuntu. This works for sure in ubuntu 2.6.31-14 (Karmic Koala) or higher, it works in lucid too. We open a terminal, go to a chosen directory and type:

wget --limit-rate=100k -e robots=off -U "Mozilla/5.0 (compatible; Konqueror/3.2; Linux)" -np -l1 -r -A .jpg -N http://goes.gsfc.nasa.gov/goeseast/argentina/3band_color/


This downloads all the images from http://goes.gsfc.nasa.gov/goeseast/argentina/3band_color/ to a directory named "goes.gsfc.nasa.gov/goeseast/argentina/3band_color/" (This dir will be created automatically).

Now we convert all these .jpg to video with the command:

mencoder "mf://goes.gsfc.nasa.gov/goeseast/argentina/3band_color/*.jpg" -mf fps=8 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000 -vf scale=640:384

That's it, now we have a video named output.avi that we can, for example, upload to youtube:



If we gather enough images, our video will get longer and more interesting. Running the same commands in a few days, will download the new pictures (ignoring the ones we already have) so we can generate longer videos by getting more pics than NASA stores at a time. I mean we can store all the pics we want from NASA before they delete them, if we keep downloading them from time to time. Imagine a weather video showing an entire month!

// TODO: crop the images to remove that jumpy black rectangle in the bottom.

The problem I encountered with this is that sometimes, NASA has pictures taken at irregular intervals of time, so the video seems to get faster or slower randomly. That's an interesting problem to think about, what to do when we want to generate a video from images but we have frames missing. Do we fill the missing frames with blanks?