Creating animations using Time Manager
In this recipe, we will use the Time Manager plugin to create an image series out of our spatiotemporal QGIS project and turn it into a video, which is ready to be uploaded on Youtube or added into a presentation using easily available and free tools.
To follow this recipe, it's advisable that you complete the previous recipe, Exploring spatiotemporal vector data using Time Manager, to set up this project.
To turn the image series exported by Time Manager into a video, we can use external programs, such as the command-line tool Mencoder, or the free Windows Movie Maker.
Mencoder is a very useful command-line tool to encode videos, which is available from repositories for many Linux distributions and for Mac. Windows users can download it from Gianluigi Tiesi's site at http://oss.netfarm.it/mplayer-win32.php.
If you're using Windows, you can also create the video using the free Windows Movie Maker application, which can be downloaded from http://windows.microsoft.com/en-us/windows/get-movie-maker-download.
Before starting the export, it is a good idea to check all the settings, as follows:
- The time slider should be moved to the beginning of the time line, and an appropriate Time frame size should be set.
- Additionally, it can be useful to enable display frame start time on map (refer to the screenshots in the previous recipe) if you haven't done so already in the previous recipe because, otherwise, the exported animation frames won't contain any information about the time of the displayed events.
- When you have found the best settings for your dataset, click on the Export Video button. A dialog will open, which will allow you to select the folder that you want to export your video to. After you click on the Select Folder button, Time Manager will automatically start to export the video frames. As displayed in the Export video information popup, you should now wait for the export to finish. There will be another popup once this process is finished, which looks like the following screenshot:
- If you open the
export folder, you will see the animation frames that Time Manager just created. - This is how you can use Mencoder to create an
.avi video from all .png images in the current working directory. Make sure that you are in the folder containing the images before running the following command: - You can control the speed of the animation using the frames per second (
fps) parameter. Higher values create a faster animation.
If you're using Windows Movie Maker, perform the following steps:
- Load the animation frame images.
- To adjust the speed of the animation, go to Video Tools | Edit, and reduce the Duration value. Note that you should have all images selected if you want to apply the same duration to all images at once.
- To save the animation, just go to File | Save Movie and select your preferred resolution and quality.
Time Manager's Export Video feature uses the QgsMapCanvas.saveAsImage() function to export the image series. This means that the images will be of the same size as the map canvas in your QGIS window at the time of clicking on the Export Video button.