NOTICE! This is a static HTML version of a legacy LOCI Software ticket.

LOCI projects are now located on GitHub. The Bio-Formats project can be found here.

Ticket #40 (closed defect: fixed)

Opened 2007-03-19T12:12:50-05:00

Last modified 2007-03-22T09:25:21-05:00

AVI writer produces incorrect video files

Reported by: curtis Owned by: melissa
Priority: minor Milestone:
Component: bio-formats Severity:
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by curtis)

The AVI writer sometimes produces videos that are skewed or scrambled. The code was originally adapted from the ImageJ AVI_Writer plugin, which does not seem to suffer from the problem (though I have not recently verified that it works properly either). I have compared the two implementations, but was unable to determine what would cause this discrepancy, so the bug is something of a mystery.

For an example, open data/tiff/mri-stack.tif into the Bio-Formats viewer, and File>Save to mri-stack.avi. The video file will be extremely skewed with many video players (I tested in Totem with the totem-gstreamer engine). The video will appear more reasonable when opened with the Bio-Formats Importer, but still slightly corrupted, especially towards the later frames at the top of the image.

Attachments

gspot.jpg (182.1 KB) - added by curtis 2007-03-21T13:33:29-05:00.
Comparison of video encoded with ImageJ vs Bio-Formats in GSpot codec identification software

Change History

comment:1 Changed 2007-03-19T12:13:44-05:00 by curtis

  • Description modified

comment:2 Changed 2007-03-19T15:25:20-05:00 by melissa

  • Status changed from new to closed
  • Resolution set to fixed

This was a bug in the AVI reader (not the writer); see r2483.

Totem (xine engine) still does not display the AVI file generated from data/tiff/mri-stack.tif (using Bio-Formats or AVI_Writer). However, the following movie players display this file correctly:

Bio-Formats
mplayer
xine
QuickTime (on Mac OS X)

Seems to me like this is a bug in Totem, but feel free to reopen if I'm missing something.

comment:3 Changed 2007-03-21T10:08:48-05:00 by curtis

  • Priority changed from major to minor
  • Status changed from closed to reopened
  • Resolution fixed deleted

I tested with ImageJ's  AVI Writer plugin, and it produces a different file than Bio-Formats does with the same input data. In particular, the ImageJ-produced video plays properly in Windows Media Player, while the Bio-Formats-produced video does not.

I have placed the two files in data/curtis/avi for comparison. I also added a (crappy) binary diff utility at source:trunk/loci/utils/BinaryDiff.java that does dumb byte comparison and outputs the differences. Running it on the two AVI files produces a long list of mostly off-by-1s -- maybe there is a difference in rounding somewhere? Probably the first few lines of output are the most interesting and useful.

Still, both videos look scrambled with totem (including the GNOME preview, which by default uses totem to generate the thumbnails). So there seem to be two separate problems here:

  1. Scrambled video in Totem.
  2. Video does not play in Windows Media Player.

The first problem could indeed be a bug in Totem. I know the videos appear incorrectly with totem-gstreamer installed. You said the BF video is also scrambled in totem-xine? If so, that does point to Totem, but I have seen many AVI thumbnails rendered with Totem, and never seen another scrambled one, leading me to believe there is something subtly wrong or at least unusual about the ImageJ and Bio-Formats AVI encoders.

The second problem is most certainly a problem, since ImageJ produces videos that work properly in Media Player.

comment:4 Changed 2007-03-21T10:20:24-05:00 by curtis

Upon further investigation, the AVI_Writer plugin available from the ImageJ web site is out of date. It has since been factored into the ImageJ core. I created a third AVI with the newest version of ImageJ, and this video does not suffer from the Totem skew problem. There are only three bytes different between it and the AVI_Writer video, so it should be very easy to figure out how to eliminate the skew problem from the Bio-Formats AVI writer.

comment:5 Changed 2007-03-21T11:45:55-05:00 by melissa

r2491 should fix the skewing problem in Totem (totem-xine, that is). The issue was that the Bio-Formats AVI writer recorded the actual width of each plane, when it needed to record the padded width (a multiple of four). The old AVI_Writer plugin does the same thing.

I can't test with Windows Media Player, but I'm guessing Bio-Formats AVI files will now open correctly.

Changed 2007-03-21T13:33:29-05:00 by curtis

Comparison of video encoded with ImageJ vs Bio-Formats in GSpot codec identification software

comment:6 Changed 2007-03-21T13:38:58-05:00 by curtis

Great, the skewing problem is fixed in totem-gstreamer as well. I replaced the Bio-Formats-encoded video at data/avi/curtis/mri-stack-bf.avi with a new version reflecting the fix.

However, the Bio-Formats video still does not play in Media Player, nor can Windows XP create a thumbnail. Both ImageJ-encoded videos, old and new, do have thumbnails. So something is different about the Bio-Formats encoder.

I tried reading the new ImageJ video and the Bio-Formats video into the  GSpot codec information and identification software, and it reports that mri-stack-bf.avi has a bad AVI header at offset 0x0ff8. See the attachment for a screenshot.

comment:7 Changed 2007-03-21T14:34:49-05:00 by melissa

Files produced using r2492 look fine in GSpot. data/avi/curtis/mri-stack-bf.avi has been replaced to reflect this fix.

comment:8 Changed 2007-03-22T09:25:21-05:00 by curtis

  • Status changed from reopened to closed
  • Resolution set to fixed

Woo, it plays in Media Player, too.