ImageJ Plugin for reading an AVI file into an image stack
(one slice per video frame)
Restrictions and Notes:
- Only few formats supported:
- uncompressed 8 bit with palette (=LUT)
- uncompressed 8 & 16 bit grayscale
- uncompressed 24 & 32 bit RGB (alpha channel ignored)
- uncompressed 32 bit AYUV (alpha channel ignored)
- various YUV 4:2:2 and 4:2:0 compressed formats (i.e., formats with
full luminance resolution, but reduced chroma resolution
- png or jpeg-encoded individual frames.
Note that most MJPG (motion-JPEG) formats are not read correctly.
- Does not read avi formats with more than one frame per chunk
- Palette changes during the video not supported
- Out-of-sequence frames (sequence given by index) not supported
- Different frame sizes in one file (rcFrame) not supported
- Conversion of (A)YUV formats to grayscale is non-standard:
All 255 levels are kept as in the input (i.e. the full dynamic
range of data from a frame grabber is preserved).
For standard behavior, use "Brightness&Contrast", Press "Set",
enter "Min." 16, "Max." 235, and press "Apply".
- Restrictions for AVIs with blank frames:
Currently only supported with AVI-2 type index.
Blank frames are ignored.
Selection of start and end frames is inconsistent between normal and
virtual stacks.
Timing in slice info is incorrect unless read as virtual stack.
- Note: As a last frame, one can enter '0' (= last frame),
'-1' (last frame -1), etc.
Version History:
2008-04-29
based on a plugin by Daniel Marsh and Wayne Rasband;
modifications by Michael Schmid
- Support for several other formats added, especially some YUV
(also named YCbCr) formats
- Uneven chunk sizes fixed
- Negative biHeight fixed
- Audio or second video stream don't cause a problem
- Can read part of a file (specify start & end frame numbers)
- Can convert YUV and RGB to grayscale (does not convert 8-bit with palette)
- Can flip vertically
- Can create a virtual stack
- Added slice label: time of the frame in the movie
- Added a public method 'getStack' that does not create an image window
- More compact code, especially for reading the header (rewritten)
- In the code, bitmapinfo items have their canonical names.
2008-06-08
- Support for png and jpeg/mjpg encoded files added
- Retrieves animation speed from image frame rate
- Exception handling without multiple error messages
2008-07-03
- Support for 16bit AVIs coded by MIL (Matrox Imaging Library)
2009-03-06
- Jesper Soendergaard Pedersen added support for extended (large) AVI files,
also known as 'AVI 2.0' or 'OpenDML 1.02 AVI file format extension'
For Virtual stacks, it reads the 'AVI 2.0' index (indx and ix00 tags).
This results in a dramatic speed increase in loading of virtual stacks.
If indx and ix00 are not found or bIndexType is unsupported, as well as for
non-virtual stacks it finds the frames 'the old way', by scanning the whole file.
- Fixes a bug where it read too many frames.
This version was published as external plugin.
2011-12-03
- Minor updates & cleanup for integration into ImageJ again.
- Multithread-compliant.
2011-12-10
- Based on a plugin by Jesper Soendergaard Pedersen, also reads the 'idx1' index of
AVI 1 files, speeding up initial reading of virtual stacks also for smaller files.
- When the first frame to read is > 1, uses the index to quickly skip the initial frames.
- Creates a unique window name.
- Opens MJPG files also if they do not contain Huffman tables
2012-02-01
- added support for YV12, I420, NV12, NV21 (planar formats with 2x2 U and V subsampling)
2012-12-04
- can read AVI-2 files with blank frames into a virtual stack
2013-10-29
- can read MJPG files where the frames don't have the same pixel number as the overall video
2015-09-28
- reads most ImageJ AVI1 files with size>4 GB (incorrectly written by ImageJ versions before 1.50b)
2017-04-21
- bugfix: file was not closed in case of dialog cancelled or some IO errors.
- Tries to recover data from truncated files.
The AVI format looks like this:
RIFF AVI RIFF HEADER, AVI CHUNK
| LIST hdrl MAIN AVI HEADER
| | avih AVI HEADER
| | LIST strl STREAM LIST(s) (One per stream)
| | | strh STREAM HEADER (Required after above; fourcc type is 'vids' for video stream)
| | | strf STREAM FORMAT (for video: BitMapInfo; may also contain palette)
| | | strd OPTIONAL -- STREAM DATA (ignored in this plugin)
| | | strn OPTIONAL -- STREAM NAME (ignored in this plugin)
| | | indx OPTIONAL -- MAIN 'AVI 2.0' INDEX
| LIST movi MOVIE DATA
| | ix00 partial video index of 'AVI 2.0', usually missing in AVI 1 (ix01 would be for audio)
| | [rec] RECORD DATA (one record per frame for interleaved video; optional, unsupported in this plugin)
| | |-dataSubchunks RAW DATA: '??wb' for audio, '??db' and '??dc' for uncompressed and
| | compressed video, respectively. "??" denotes stream number, usually "00" or "01"
| idx1 AVI 1 INDEX ('old-style'); may be missing in very old formats
RIFF AVIX 'AVI 2.0' only: further chunks
| LIST movi more movie data, as above, usually with ix00 index
Any number of further chunks (RIFF tags) may follow
Items ('chunks') with one fourcc (four-character code such as 'strh') start with two 4-byte words:
the fourcc and the size of the data area.
Items with two fourcc (e.g. 'LIST hdrl') have three 4-byte words: the first fourcc, the size and the
second fourcc. Note that the size includes the 4 bytes needed for the second fourcc.
Chunks with fourcc 'JUNK' can appear anywhere and should be ignored.