Personal tools
You are here: Home cmgui Wiki mpeg2enc
Views

History for mpeg2enc

changed:
-
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.";


From snie007 Wed Aug 3 09:09:31 +1200 2005
From: snie007
Date: Wed, 03 Aug 2005 09:09:31 +1200
Subject: Novice (copy and paster's) notes
Message-ID: <20050803090931+1200@https://cms.bioeng.auckland.ac.nz>

when using the command  
 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

If your file names do not have a fixed number of digits in there ordering number, then change
 jpg/%05d.jpg to  jpg%d.jpg

and if you get an error like 
**ERROR: [yuvscaler] Unconsistent USE keyword: USE_720x576+22+0, offsets/sizes not multiple of 2 or offset+size>input size

try just deleting every thing between the first and second |

so you get 
jpeg2yuv -f 25 -I p -b 0 -j jpg%d.jpg | mpeg2enc -f 3 -b 3800 -a 2 -4 2 -2 3 -s -F 3 -np -q 1 -v 1 -o movie.m2v



From taus007 Fri Sep 22 13:39:31 +1200 2006
From: taus007
Date: Fri, 22 Sep 2006 13:39:31 +1200
Subject: Duplicate (n times) files to create slower movie
Message-ID: <20060922133931+1200@www.cmiss.org>

See new entry at http://www.cmiss.org/cmgui/wiki/BitsOfPerl on using perl to duplicate images so that you can slow down a movie.

Nothing complex here but a useful piece of code if you are trying to string together only a handful of images and make a movie.

Contributing to this site

Please add to the wiki any relevant information that you think might be useful to other users of this website. For example, you might like to contribute your experiences, questions and answers.

You are encouraged to contribute to this site regardless of your level of experience. Contributions are welcomed from new and regular visitors.

If you ask a question and receive an answer from a developer you should record it in the wiki. This information is extremely useful and can help other users overcome the same problem.

See how to add and edit pages for more information.