How to encode XviD movies

From Sblwiki

Jump to: navigation, search

Lee Pang 13:24, 19 October 2006 (PDT)

Contents

Overview

The data generated from time-lapse imaging runs is generally best viewed as an animated movie. However, a movie generated from an image set that corresponds to a 24hr session can easily exceed 100-200MB making it difficult to share and incorporate into talks. To make files easy to share, various compression codecs can be used, however most of them use lossy algorithms, resulting in lower image quality, and in many cases poor compression ratios. This document will describe the tools and steps required to generate a movie using XviD compression which provides at least a 50:1 compression ratio without significant loss of image quality.

Requirements

A note on the requirements: if doing this on a Mac you'll need a substitute for VirtualDub. There are Mac compatible versions of ImageJ and the XviD codec, however, using the Quicktime format may be better in this scenario

Procedure

  1. If you haven't done so already, install ImageJ, VirtualDub, and the XviD codec, in that order.
  2. Import/create an image stack in ImageJ.
  3. Apply any corrections needed (e.g. camera offset subtraction, background subtraction, and flatfield correction). Note: for our imaging system, you need to subtract a value of 215=32768 from each image in the stack, assuming you captured your image set with 16-bit pixel depth. This is because LabVIEW 7.1 and NI-IMAQ does not support unsigned integers in image data.
  4. Annotate with event and time stamps as needed.
  5. Export the stack as an AVI movie using the AVI writer plugin (or equivalent).
  6. Open the AVI file in VirtualDub.
  7. In the menu, goto Video -> Compression ...
  8. Select XviD MPEG-4 Codec from the listing in the dialog box.
  9. Click on the 'configure' button
  10. In the XviD Configuration dialog box move the slider to select the quality of the output video (target quantizer, usually a value <5 is best) and hit 'OK'.
  11. Click 'OK' on the Compression Configuration dialog box.
  12. Goto File -> Save as AVI
  13. Name the output file something different than your original otherwise VirtualDub will overwrite it.
  14. Hit 'Save' to begin the (re)compression process.

Additional notes and caveats

  • Make sure that VirtualDub is under 'normal recompress' or 'full processing' mode (under the Video menu).
  • For faster processing uncheck 'Show input video' and 'Show output video' in the processing status display.
  • There are plenty of other things that VirtualDub can do aside from recompressing video. Other operations that one may find useful are:
    • splitting an AVI into individual files, or a series of shorter AVIs
    • video 'cropping' - e.g. shortening a video to a subset of frames
    • changing playback framerate and dropping/adding keyframes
    • adding audio
  • There is only one caveat: in order to playback an XviD compressed video, the machine must have the XviD codec installed and a compatible player.
Personal tools