How to build lammps with ffmpeg support?

Dear all
I need to dump movie with Lammps. I saw Lammps should be built with ffmpeg flag. Besides the “LMP_INC = -DLAMMPS_GZIP -DLAMMPS_JPEG -DLAMMPS_PNG -DLAMMPS_FFMPEG”, is there anything else should be added with the Makefile?
Thanks a lot and best regards!

Jian

Dear all
I need to dump movie with Lammps. I saw Lammps should be built with ffmpeg
flag. Besides the "LMP_INC = -DLAMMPS_GZIP -DLAMMPS_JPEG -DLAMMPS_PNG
-DLAMMPS_FFMPEG", is there anything else should be added with the Makefile?

some comments:

a) movies can also be created after the fact with software packages
that can read regular LAMMPS trajectory dumps.
b) another way to create movies is to have lammps dump multiple images
and then combine these images to a movie (which can be done with
ffmpeg, mencoder or other tools).
c) ffmpeg support requires the one define and a suitable ffmpeg
executable. it works by launching the ffmpeg executable through a pipe
and passing image directly through the pipe, so it is like option b)
without having to store temporary files.
d) the precompiled LAMMPS executables from rpm.lammps.org already
contain ffmpeg support and the windows version also bundles a suitable
ffmpeg executable. for Fedora/RHEL/CentOS it can be installed from
rpmfusion.

axel.

Even though this is not the answer to your question, and probably
belongs on the VMD list, here is how I generate movies of LAMMPS
trajectories.

The visualization options in LAMMPS are pretty cool, but if you need
to generate fancy graphics, you have a lot more options if you use 3rd
party visualization programs. Since I'm familliar with VMD, that's
what I'll suggest. (For other software, check here:
http://lammps.sandia.gov/prepost.html)

Feel free to ignore this entire email.

1) Load a LAMMPS trajectory into VMD
  ...For instructions how to do this, and recommendations for to make
the images look nice, see section 4.5 (page 19) and appendix C.2 (pp.
55-56) of this file:
http://www.moltemplate.org/doc/moltemplate_manual.pdf

Comment: You can use VMD to directly generate movies of your
trajectory. (To do that, skip step 3c below). However I don't
recommend this approach because the encoding quality of the movies is
kind of low, and you are stuck with using 25fps. I prefer to use VMD
to generate a series of images from the movie you will make, and use
an independent program (like "avconv", "ffmpeg", "mencoder", or
"Gimp->GAP", or perhaps QuicktimePro) to stitch those frames into a
movie.

2) Choose the resolution of the frames in the movie. (Note: "avconv"
requires the x and y resolution to be divisible by 2.)
    To do that in VMD, select the "Extensions"->"Tk Console" menu
option, and type in "display resize 800 600", (or whatever size you
prefer, and hit Enter.)

3) Select the VMD "Extensions"->"Visualization"->"Movie Maker" menu option.
   3a) Select the "Movie Settings"->"Trajectory" menu option (from the
"VMD Movie Generator" window).
   3b) Click on the "Set working directory" button and make sure it
points to a directory where you can write to.
   3c) (optional, but recommended) Select the "Format"->"Targa Frames"
menu option.
   3d) (optional, but recommended) Select the "Renderer"->"Internal
Tachyon" menu option (will slow down rendering, but higher quality. I
often use ambient occlusion lighting. To do that, go back to the "VMD
Main" window and select the "Display"->"Display Settings"->"Amb. Occl"
menu option.)
   3e) Click on the "Make Movie" button.

4) After step 3e, you should have a directory full of images (with
names like: "final.untitled.00000.tga", "final.untitled.00001.tga",
"final.untitled.00002.tga", ...). (That is, unless you skipped step
3c and used VMD to create a movie. If you did that, then skip reading
this email. You are done.)

The last step is to assemble these images into a movie.

---------------- Instructions for using "avconv" ----------------

The remaining instructions assume you have installed the "avconv" on
your computer (ubuntu installation instructions below). "avconv" is a
new fork of "ffmpeg". You will also have to install the codecs you
want to use. (For information how to do that in ubuntu or debian or
mint, see below.)

  To make an .mp4 file, using "avconv" try this:

aavconv -r 18 -f image2 -i "final.untitled.%05d.tga" -codec:v libx264
-crf 6 movie.mp4

  To make a .webm file, use:

avconv -r 18 -f image2 -i "final.untitled.%05d.tga" -codec:v libvpx
-crf 6 -b:v 100M movie.webm

  To make a .mov file, use:

avconv -r 18 -f image2 -i "slicer%03d.png" -codec:v libx264 -crf 6
-pix_fmt yuv420p movie.mov

  Note: the number after the "-r" argument selects the frames per
second. (18fps in these examples)

  Note: the number after the "-crf" argument selects the encoding
quality of the movie. (6 in this example.) Lower numbers result in a
higher quality (and larger) movie. A number less than 20 is
recommended.

If you are using ubuntu linux, you can install the software you need
with these commands:

  sudo apt-get install libav-tools imagemagick
  sudo apt-get install libavcodec-extra libvpx # (popular codecs)

---------------- Instructions for using "ffmpeg" ----------------

I have not tried using "ffmpeg", but I looked this up at work.
Try this:

ffmpeg -f image2 -i final.untitled.%05d.tga -r 25 -an -b 10000k -bt
10000k output.mov
ffmpeg -f image2 -i final.untitled.%05d.tga -r 25 -an -b 10000k -bt
10000k output.asf

Installation instructions for "ffmpeg" on Red Hat Enterprise Linux 6
http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat

---------------- Instructions for using "mencoder" ----------------

I have not tried this either, but try "mencoder" if you can not
install "avconv" or "ffmpeg".

Given a directory full of sequentially numbered TGA (targa) files:

mencoder "mf://*.tga" -o movie.avi -ovc lavc -lavcopts vcodec=mjpeg

or:

mencoder "mf://*tga" -o output.mpeg -ovc lavc -mpegopts
format=mpeg2:tsaf:vbitrate=4000 -fps 10 -vf scale=400:400

Otherwise:

mencoder "mf://@file.txt" -o output.mpeg -ovc lavc -mpegopts
format=mpeg2:tsaf:vbitrate=4000 -fps 10 -vf scale=400:400

Hope this helps.

Andrew