Granular.jl

Julia package for granular dynamics simulation
git clone git://src.adamsgaard.dk/Granular.jl
Log | Files | Refs | README | LICENSE

commit 0fc41a6f811b5970151c7960686a4e6d1e9603bc
parent eb7cdca84697284acd902a7c63846255851291f2
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Mon,  7 May 2018 16:06:13 -0400

Convert animations to mp4 with ffmpeg if available

Diffstat:
Msrc/io.jl | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/io.jl b/src/io.jl @@ -1067,7 +1067,8 @@ from the shell using the supplied `pvpython` argument. * `images::Bool`: render images to disk (default: true) * `gif::Bool`: merge images as GIF and save to disk (default: false, requires `images=true`) -* `animation::Bool`: render animation as AVI to disk (default: false) +* `animation::Bool`: render animation as movie to disk (default: false). If + ffmpeg is available on the system, the `.avi` file is converted to `.mp4`. * `trim::Bool`: trim images in animated sequence (default: true) * `reverse::Bool`: if `images=true` additionally render reverse-animated gif (default: false) @@ -1084,6 +1085,19 @@ function render(simulation::Simulation; pvpython::String="pvpython", try run(`$(pvpython) $(simulation.id)/$(simulation.id).py`) + if animation + try + run(`ffmpeg -i $(simulation.id)/$(simulation.id).avi + -vf scale='trunc\(iw/2\)\*2:trunc\(ih/2\)\*2' + -c:v libx264 -profile:v high -pix_fmt yuv420p + -g 30 -r 30 -y + $(simulation.id)/$(simulation.id).mp4`) + if isfile("$(simulation.id)/$(simulation.id).mp4") + rm("$(simulation.id)/$(simulation.id).avi") + end + end + end + # if available, use imagemagick to create gif from images if images && gif try