[Gdal-dev] Animation?

Didrik Pinte dpinte at itae.be
Tue Mar 21 03:16:44 EST 2006


Le lundi 20 mars 2006 à 15:24 -0800, Tyler Mitchell a écrit :
> Didrik,
> I'd love to hear more about how you did the Python, Mplayer animation bit.  Sounds really interesting.  I can't quite wrap my head around MPlayer, but am very familiar with python - so I'd love to see what you did.
> 
> Tyler

That was pretty easy in fact. 

My need was to create a movie using pictures created by MapServer (a
moving tank during an agricultural season). I've used python mapscript
to pilot mapserver and create png output pictures. Then a really really
simple call to mplayer does the trick and build a beautiful movie.

Here is the extract used to build the movie :

def createMovie(basePath,path):
        '''
        Create a movie using all the pictures stored in the basePath
(png files). The movie is compressed using Microsoft codec msmpeg4v2 in
order to be readable on windows computers. The frames per second are
fixed at 1. 
	TODO : 	- use popen to redirect stdout and stderr
		- make a second pass for better compression/quality
        '''

        try:
                os.system('/usr/bin/mencoder "mf://%s/00*.png" -mf
type=png:fps=1  -ovc lavc -lavcopts vcodec=msmpeg4v2:vpass=1:$opt
-nosound -o %s '% (basePath,path))
        except:
                log.error("Error during movie creation")
                return False
        return os.path.exists(path)

Pretty easy ;-)

I did it on a Linux computer but it's obvious that it can be done on a
Windows computer with a full mplayer installation.

Didrik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Ceci est une partie de message
	=?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20060321/6dfd089f/attachment.bin


More information about the Gdal-dev mailing list