Skip to content

Commit

Permalink
Add script to make a movie from simulation images (#779)
Browse files Browse the repository at this point in the history
### Description
This adds a Bash script to process a sequence of image files (`*.png`)
in the current working directory into a H.264-encoded `*.mov` movie,
with a text annotation for consistent branding of Quokka simulation
movies.

### Related issues
N/A

### Checklist
_Before this pull request can be reviewed, all of these tasks should be
completed. Denote completed tasks with an `x` inside the square brackets
`[ ]` in the Markdown source below:_
- [x] I have added a description (see above).
- [x] I have added a link to any related issues see (see above).
- [x] I have read the [Contributing
Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md).
- [ ] I have added tests for any new physics that this PR adds to the
code.
- [ ] I have tested this PR on my local computer and all tests pass.
- [ ] I have manually triggered the GPU tests with the magic comment
`/azp run`.
- [x] I have requested a reviewer for this PR.
  • Loading branch information
BenWibking authored Nov 1, 2024
1 parent 7a8dc75 commit d3e2ca2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/make_movie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

CONVERT_EXE=$(which convert) # install with: "spack install imagemagick"
RENAME_EXE=$(which rename) # install with: "spack install rename"
FFMPEG_EXE=$(which ffmpeg) # install with: "spack install ffmpeg+libx264+drawtext"

set -x

## rename *.png files

$RENAME_EXE 's/\d+/sprintf("%07d",$&)/e' -- *.png

## resize frames

for file in *.png;
do
$CONVERT_EXE $file -resize 2048x2048 $(basename -s .png $file).resize_large.png
done

## make movie
FPS=10
FILTERS="pad=ceil(iw/2)*2:ceil(ih/2)*2:color=white, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf:text='QUOKKA Simulation':fontcolor=white:fontsize=48:box=1:[email protected]:boxborderw=5:x=0.9*(w-text_w):y=0.9*(h-text_h)"

$FFMPEG_EXE -framerate $FPS -pattern_type glob -i "*.resize_large.png" -r $FPS -vcodec libx264 -vf "$FILTERS" -pix_fmt yuv420p -preset slow -tune animation -crf 18 movie_large.mov

0 comments on commit d3e2ca2

Please sign in to comment.