From 63ece1a9b4d6baaedcce9287b5b3f5acd2845271 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Fri, 1 May 2020 07:16:05 +0200 Subject: [PATCH] added animate script, clarified nixos usage in readme --- README.md | 4 ++-- animate | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100755 animate diff --git a/README.md b/README.md index 242e82d..9061924 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Visit the website at [renders.datenvorr.at](https://renders.datenvorr.at) ## Compiling: ```bash -# load requirements -nix-shell --run fish +# load dev environment (for nixos. this loads just gcc and gdb) +nix-shell # run gcc with flags gcc -lm -Wall -Wextra -o march.out main.c ``` diff --git a/animate b/animate new file mode 100755 index 0000000..577aed9 --- /dev/null +++ b/animate @@ -0,0 +1,39 @@ +#!/usr/bin/env fish + +# settings: +set step 0.002 # power increase for each frame +set start 1 # starting power +set end 3 # end power + +# internal vars: +set counter 1 # internal counter for numbering images +set pos "$start" # current power + +# render a frame. power is $argv[1] and counter is $argv[2] +function render + ./march.out $argv[1] "out/3/"(num $argv[2])".bmp" > /dev/null +end + +# pad counter with zeroes to the left +function num + printf "%05i" $argv[1] +end + +# iterate over all frames and draw them +while test "$pos" -lt "$end" + render "$pos" "$counter" + set pos (math "$pos" + "$step") + set counter (math $counter + 1) + set percent (math "ceil((($pos - $start) / ($end - $start)) * 100)") + echo -ne "\r$percent% ($start -> $pos -> $end) " +end + +echo to convert the frames to a video, use ffmpeg like this: +echo ffmpeg -r 60 -f image2 -s 1080x1080 -i %05d.bmp -vcodec h264 -crf 20 animation.mp4 +echo +echo explanation: +echo " -r 60 60 fps output video" +echo " -s 1080x1080 video resolution" +echo " -i %u5d.bmp file name format" +echo " -vcoded h264 video codec" +echo " -crf 20 quality. 25 is best, 15 is pretty bad"