""" wave = lambda x, f : sin ( f * x ) envelope = lambda x, l : exp ( - ( x - l ) ** 2 ) x = linspace ( - 5, 5, 2000 ) positions = linspace ( - 5, 5, 50 ) # Plot all the individual frames for i, pos in enumerate ( positions ): y = wave ( x, 10 ) * envelope ( x, pos ) z = envelope ( x, pos ) # Plot the frame figure () plot ( x, z, color = ( 0.5, 0, 0 )) plot ( x, - z, color = ( 0.5, 0, 0 )) plot ( x, y, color = ( 0, 0, 1 )) ylim ( - 1.3, 1.3 ) # Save the with a filename that ensures correct order on the filesystem savefig ( "wave_" + ( 5 - len ( str ( i ))) * "0" + str ( i ) + ".png" ) def make_animation_video ( filenamebase, animfilename ): """A function that takes frames and composes them into a video. The man pagesĪlso provide a clean description of the parameters and show some useful examplesįrom numpy import * from pylab import * import os import subprocess as sp def make_frames (): """This function generates the images (frames) of the animation. Look at the documentation available on the webpages mentioned above. Mencoder is responsible for encoding videosĭescribing these tools is far beyond the scope of this document. Mplayer can play almost anyįile format and has a huge set of options. Of the most versatile tools for working with video data. To encode videos we use the famous mplayer / mencoder toolbox. Sometimes is faster, uses less memory and the resulting files are smaller in size. (This is not the only tool that can compose gif files, you may also try gifsicle We use this tool for creating animated gif images. The first of these tools is called convert which is itself part of the well known Proposed at the beginning of this tutorial. We additionaly need two programs which are not part of the python installation as The time! (By the way, the file animwave.flv from the example below has a size Tuned for areas and can introduce bad artefacts if the image has only a bunch sharp For example the video compression algorithms are Of options interacting in a complex manner. But mature video encoding tools usually have a huge number (The file animwave.gif from the example below has a size ofįor longer animations you should of course use the advantages of modern videoĬompression techniques. If you only have a couple of images, say up to 50 frames, then animgifs are probably Images tend to be larger in file size, but will yield good results without much technicalities. Videos: use some video compression algorithm and are placed inside a data container.īoth of these options have their respective advantages and disadvantages.gif image file format (so called animgifs). There is more than one way to make animations. This is also exactly the way we will create animations: in a first step we draw each image (weĬall this a frame) and after we got all the frames, we will glue them together. An animation is nothingĮlse than a pile of images which are shown one after the other. Thus we take the opportunityĪnd explain in this section how to generate simple animations. Plots are nice but sometimes an animation is even better.
0 Comments
Leave a Reply. |