"movie" of the 2d Rayleigh-Benard convection

142 views
Skip to first unread message

Jack

unread,
Aug 3, 2018, 11:00:56 AM8/3/18
to Dedalus Users
Hi Dedalus Users,

There are online tools (such as http://gifmaker.me/) to make gif using images. Can the example code plot_2d_series.py
be adapted (easily?) to generate a "movie" of the 2d Rayleigh-Benard convection?


Jack

Jeffrey S. Oishi

unread,
Aug 3, 2018, 11:05:16 AM8/3/18
to dedalus-users
Hi Jack,

Yes, though I'm not sure I fully understand your question. plot_2d_series.py outputs a series of png frames, which can be assembled into a movie at that site. You can also use something like ffmpeg on linux or mac, which you will have to install on your machine if you don't have it. I typically use ffmpeg to make movies like those you see at the dedalus vimeo site (https://vimeo.com/dedalus), though I think some mac users might use different programs.

Jeff

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To post to this group, send email to dedalu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dedalus-users/b3837154-dcf1-4c3e-b43d-fdc11172a2b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeffrey S. Oishi

unread,
Aug 3, 2018, 11:09:26 AM8/3/18
to dedalus-users
I should also add that ffmpeg has a LOT of options. Here's how I typically call it, using a little bash function written by Keaton. I just put this in my .bashrc, and then use that example to make a 30 frames per second movie. If you want a lower frame rate, just change the third argument to something like 15.

 PNG encoding with ffmpeg
# Example use: png2mp4 “frames/*" frames.mp4 30

# Options:
#   -y                  Overwrite output
#   -f image2pipe       Input format
#   -vcodec png         Input codec
#   -r $3               Frame rate
#   -i -                Input files from cat command
#   -f mp4              Output format
#   -vcodec libx264     Output codec
#   -pix_fmt yuv420p    Output pixel format
#   -preset slower      Prefer slower encoding / better results
#   -crf 20             Constant rate factor (lower for better quality)
#   -vf "scale..."      Round to even size
#   $2                  Output file
function png2mp4(){
    cat $1 | ffmpeg \
        -y \
        -f image2pipe \
        -vcodec png \
        -r $3 \
        -i - \
        -f mp4 \
        -vcodec libx264 \
        -pix_fmt yuv420p \
        -preset slower \
        -crf 20 \
        -vf "scale=trunc(in_w/2)*2:trunc(in_h/2)*2" \
        $2
}

Yu Cao

unread,
Aug 3, 2018, 11:12:23 AM8/3/18
to dedalu...@googlegroups.com
Hi Jeff, 

Once one has the outputs of plot_2d_series.py, one can use that site or ffmpeg to make movies. I was wondering if one can modify plot_2d_series.py so that
one directly gets a movie output. (It seems that there is no need to do so according to your comment.)


Jack

On Fri, Aug 3, 2018 at 11:05 AM Jeffrey S. Oishi <jso...@gmail.com> wrote:

Jeffrey S. Oishi

unread,
Aug 3, 2018, 11:29:53 AM8/3/18
to dedalus-users
Hi Jack,

Sure. Just put the call to ffmpeg in the python script using something like subprocess.run (https://docs.python.org/3/library/subprocess.html)

Jeff

Reply all
Reply to author
Forward
Message has been deleted
0 new messages