Created
February 25, 2020 01:42
-
-
Save cosinekitty/437f9343deeb1e55720066d4176b0bba to your computer and use it in GitHub Desktop.
Bash script for creating the Mandelbrot Set zoom movie.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| Fail() | |
| { | |
| echo "FATAL($0): $1" | |
| exit 1 | |
| } | |
| # Compile the source code for mandelzoom. Optimize for speed. | |
| echo "Building C++ code..." | |
| g++ -Wall -Werror -Ofast -o mandelzoom mandelzoom.cpp lodepng.cpp || Fail "Error building C++ code." | |
| # Destroy the "movie" directory and its contents, if it exists. | |
| rm -rf movie || Fail "Error deleting movie directory." | |
| # Create a brand new, empty "movie" directory, for holding the output files. | |
| mkdir movie || Fail "Error creating movie directory." | |
| # Run the mandelbrot generator. This creates all the output PNG files. | |
| ./mandelzoom movie $((30*30)) -0.74498410019 -0.13523854817 1.0e8 || | |
| Fail "Error running Mandelbrot Zoom program." | |
| # Convert the PNG files to a video file zoom.mp4. | |
| # Explanation of the ffmpeg command-line arguments: | |
| # "-r 30" means 30 frames per second | |
| # "-f image2" : convert a series of images to a video. | |
| # "-s 1280x720" indicates the dimensions of the output video, in pixels. | |
| # "-i movie/frame_%05d.png" specifies filenames of the series of png files to be used as input. | |
| # "-vcodec libx264": the codec library to use. See: https://www.videolan.org/developers/x264.html | |
| # "-crf 15" : Constant Rate Factor, specifies amount of lossy compression. https://trac.ffmpeg.org/wiki/Encode/H.264 | |
| # "-pix_fmt yuv420p" defines how colors are encoded in an mp4 file. https://en.wikipedia.org/wiki/YUV | |
| # "zoom.mp4" is the output filename. | |
| ffmpeg -r 30 -f image2 -s 1280x720 -i movie/frame_%05d.png -vcodec libx264 -crf 15 -pix_fmt yuv420p zoom.mp4 || | |
| Fail "Error in ffmpeg." | |
| echo "Created movie zoom.mp4" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment