Personal tools
You are here: Home / cmgui / Wiki / mpeg2enc
Navigation
Log in


Forgot your password?
 

mpeg2enc

To scale an image down from 768x576 to 720x576 (NB/ the maximum width images that can be used to make a movie using mpeg2enc is 720)

jpeg2yuv -f 25 -I p -b 0 -j jpg/%05d.jpg | yuvscaler -I USE_720x576+22+0 -O   SIZE_720x576 | mpeg2enc -f 3 -b 3800 -a 2 -4 2 -2 3 -s -F 3 -np -q 1 -v 1 -o movie.m2v

This command makes a .m2v movie with a frame rate of 25/second (-f 25). For other specifications see the man pages for mpeg2enc, jpeg2yuv and yuvscaler.

Note that for making movies you should not use jpg images printed directly from cmgui. There are two reasons.

1 The jpg images printed from cmgui are lossy and are poor quality

2 jpeg2yuv will seg fault

The solution is to write out lossless format images (eg sgi) and then convert them to jpg using imagemagick, with no compression. eg 'convert -type TrueColor -quality 100 bob.sgi bob.jpg'. (There will still be compression of the jpegs here but it will be much less than the default from cmgui. It is preferable to avoid the lossy jpegs altogether as described below. Incidently there is a lossless jpeg format but that is a different compression scheme altogether and probably not supported by jpeg2yuv or your normal convert.) Note that if you do not specify the type then converting may give you a mixture of gray scale and true color images. This is because by default the convert command will attempt to convert to an optimal type for a given image. An image which contains only gray colours will therefore be stored as a grayscale type. You can check the type of your image by opening it in gimp. If you have mixed types of images you will get an error when making a movie. A useful script for converting a bunch of sgi images is available here http://www.cmiss.org/cmgui/wiki/sgi2jpg.pl

NOTE: if you want to play your .m2v movie in a windows powerpoint presentation, you can simply change the .m2v extension to .mpeg

SGI files direct to movie

Here is a script that no longer requires the sgi image files to be converted to jpgs first, this script converts the images on the fly and uses ppmtoy4m instead of jpeg2yuv as recommended on the jpeg2yuv web page. This script is set up for square images. This is a perl script and uses bash for the shell but still suffers from expanding the list on the command line so it will only allow a limited number of files

Update. 12 July 2006 : Newer versions of mpegtools seem to generate by default a format from ppmtoy4m that is incompatible with mpeg2enc giving this error:

**ERROR: [yuvscaler] Could'nt read YUV4MPEG header!

To fix this I have added a parameter 'ppmtoy4m -S 420mpeg2' to 'ppmtoy4m' that specifies a format that 'mpeg2enc' understands.:

use strict;
my @movie_files = map {"activation_streaklines.$_.sgi"} (-15..119);
system("for i in @movie_files ; do convert \$i ppm:- ; done | ppmtoy4m -S 420mpeg2 | yuvscaler -O SIZE_576x576 | mpeg2enc -f 3 -b 3800 -a 1 -4 2 -2 3 -s -F 3 -np -q 1 -v 1 -o movie.mpg") and die "Unable to generate movie.";