Encoding PPI and RHI Image Series into Time-Lapses

Images rendered in viewScan.py are named according to their date and time, meaning that they are ordered both alphabetically and chronologically. Because of this, animating frames in proper order is made easy, and can be done in two different ways:

  • Creating GIFs from small image series: If the chosen image series isn't very large (not exceeding 100 frames), it's often practical to make it into a GIF animation. GIFs are convenient for website users, and easier to make than MP4s. But if they are too large, they tend to take awhile loading. To create a GIF animation, first create a separate folder for the chosen image series and put the images into that folder. Once you're inside this folder, use the 'convert' command. '*.png' tells the computer to use all PNGs from your current folder in alphabetical order. '-delay' determines time-lapse speed. '-loop 0' causes the GIF to repeat indefinitely. And the filename at the end of the command determines the time-lapse name. All together, an ordinary GIF command should look like this:

    convert *.png -delay 800 -loop 0 output.gif

  • Creating MP4s from large image series: If the chosen image series is very large, it's better to make an MP4 time-lapse. MP4s can cover large spans of time, be uploaded to YouTube, embedded in websites, and archived. However, the process of creating them is a little trickier than creating GIFs. Start with making a new subdirectory (e.g., 'Movie') in the directory containing the image series of choice. You must then tell the computer to copy the series into the subdirectory, and rename the frames as four-digit numbers in the same order. This requires the following line of code:

    k=0;for f in `ls REAL*.png`;do cp $f `printf Movie/%04d.png $k`;((k++));done
    Once this is done, PNGs in the subdirectory should be numbered 0000.png, 0001.png, etc. From inside the subdirectory, use the x264 command to render it into an MP4, with '--fps' as a frames-per-second parameter and '-o' indicating the intended name of the time-lapse file. All together, an ordinary MP4 command should look like this:
    x264 --crf 12 --fps 10 -o output.mp4 %04d.png