HOWTO: General images -> movie conversion (starting with how to make image output from OpenDX which can be skipped by many)

1's picture

** SKIP UNTIL THE NEXT "**" IF YOU DON'T CARE ABOUT OPEN DX

Open DX, at least version 4.4.4 which comes with Debian Lenny, does not have the ability to make mpg or avi animations directly.

The usual procedure is to export your dx animation in some lossles image compression format e.g. miff and then use package mjpegtools to create a high-quality mpg.

Open DX part:
1) Select continuous saving in the Image module. Select the format (e.g miff). If you allow re-rendering you can refine the resolution. Pay attention to choose an even number for image height.
2) Run the visual program.
3) The program should have created name.miff file.

** OPEN DX INSTRUCTION ENDS

Image conversion:
mjpegtools supports conversion of ppm images to mpg. If you have ImageMagick installed (available as Debian package), you should run:
convert -depth 8 -compress Undefined name.miff name.ppm

Creating mpeg:
Here we use two programs from mjpegtools, ppmtoy4m and mpeg2enc:
cat name.ppm | ppmtoy4m -F25:1 -S420mpeg2 | mpeg2enc --format 3 -video-bitrate 5000 --motion-search-radius 32 --no-constraints -o name.mpg

The result is a pretty good mpeg which can add some spice to your presentation.

Notes:

There are other explanations about the procedure which I found that do not work for my version of dx, imagemagick and mjpegtools. Namely, the information I started with did not include -S420mpeg2 as a flag to ppmtoy4m, and also did not include -depth 8 and -compress Undefined as flags to convert. -S option controls the subsampling, and 4:2:0 is the option which currently mjpegtools only support. Further, ppmtoy4m complained about the channel depth and "magic number" or whatever in first ppm-s that I created via convert. I later found out that dx saves images with depth of 16 instead of 8 which is the only acceptable value for ppmtoy4v. Also, convert has weird behaviour considering that magic (byte ?) which sometimes gives proper results by default, and sometimes not. Finally, I found out that if given the -compress Undefined flag, it will create an output with appropriate magic. Oh, yes -F 25:1 sets the framerate, choose a diffwerent ratio if you want. Lastly, the effects of options given to mpeg2enc are unknown to me, I ripped them off from somewhere, I can just confirm they create a nice output mpeg.

HTH