Login  Register

Re: AVI re-opening problem

Posted by Franklin Shaffer-2 on Sep 25, 2015; 7:23pm
URL: http://imagej.273.s1.nabble.com/AVI-re-opening-problem-tp5014442p5014473.html

Michael,
Thank you for looking into this and explaining.

For legal reasons, I must use a completely uncompressed format.  I can work around this by using TIFF sequences until I must go to uncompressed AVI.  Then I can use virtualDub to repair the AVI so ImageJ will read the entire AVI.

You all will have to decide where this ranks in your priority of work to do on ImageJ.

ImageJ is an excellent tool. It's a great example of federally funded R&D.
It's also a great example of a community of researchers working together from all over the world.

Frank

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid
Sent: Friday, September 25, 2015 3:10 PM
To: [hidden email]
Subject: Re: AVI re-opening problem

Hi Frank,

looking at the code, I can confirm that this is a problem of the AVI_Writer of ImageJ.

Here are a few more details on what happens:

If the size of the data (plus a small bit of overhead) is above 2 GB, but below 4 GB, it creates an AVI file that  does not strictly adhere to the standard, but is still readable by many programs (including ImageJ itself). If it's above 4 GB, it does not work any more. That's because the AVI_Writer still writes everything into a single 'movi' chunk, which has a 32-bit integer for the length of the 'movi' chunk.
The consequences of a file size > 4GB, when reading the AVI file:
(1) Jumping over the 'movi' chunk to find the index 'idx1' does not work (the AVI-type 1 index must be at the end), and
(2) When reading the frames sequentially, ImageJ stops when it reaches the length modulo 4 GB, because it only reads up to the length reported in the

Workaround:
For an uncompressed file size of 6.9 GB, it will usually help to use 'png' compression when saving (this is lossless for 8-bit and RGB images). If the data are not too noisy, it will reduce the file size to less than 4 GB. But it will be slower and won't help for much larger movies.

In my view, the only clean solution, adding AVI 2 capabilities to the the AVI_Writer, requires some work. I'll have a look at this, but I can't promise anything.

Michael
________________________________________________________________
On Sep 25, 2015, at 18:41, Shaffer, Franklin D. wrote:

> Michael,
> Here's a test I did based on your request:
>
> 1. I set ImageJ memory at 80 GB
> 2. I opened an AVI file with size of 6.9 GB.  I had saved it with ImageJ as AVI uncompressed.
> 3. The file opened to 1063 of 2501 frames and stopped. So ImageJ opened 2.9 GB of the 6.9 GB AVI file.
> 4. In Help-->About ImageJ it says it has used "3051 of 80000 MB"
> 5. I then closed the AVI file and turned on debug mode.
> 6. Opened the AVI file again, same thing happened.  The entire ImageJ log is pasted below.
> 7. Opened the AVI in virtualDub. It opened but had to be repaired.  Here's what virtualDub said:
> " [!] AVI: Index not found or damaged -- reconstructing via file scan.
> [!] AVI: Keyframe flag reconstruction was not specified in open options and
>    the video stream is not a known keyframe-only type.  Seeking in the video
>    stream may be extremely slow."
>
> Thanks, Frank
>
> The ImageJ log:
> setKeyUp: -1
> actionPerformed: time=1443198565264,
> java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=Open...,when=144319856
> 5264,modifiers=] on menuitem0
> runPlugIn: ij.plugin.Commands("open")
> openImage: "ojj",
> E:\OHMSETT\Oct29\proc'd_cines\Test_19_3in_OIL_419GPM_500fs\img_seq\Tes
> t_19_3in_OIL_419GPM_500fs.avi OPEN AND READ AVI FILE HEADER  (t=0 ms)
> File header: File type='RIFF' (should be 'RIFF') (t=0 ms) File header:
> RIFF type='AVI ' (should be 'AVI ') Searching for 'hdrl', found hdrl'
> 0x14-0x4eb (1240 Bytes) Searching for 'avih', found avih' 0x20-0x57
> (56 Bytes) AVI HEADER (avih): (t=10 ms)
>   dwMicroSecPerFrame=142857
>   dwMaxBytesPerSec=0
>   dwReserved1=0
>   dwFlags=16
>   dwTotalFrames=2501
>   dwInitialFrames=0
>   dwStreams=1
>   dwSuggestedBufferSize=0
>   dwWidth=2494
> setKeyUp: 10
>   dwHeight=1196
> Searching for 'strl', found strl' 0x60-0x4eb (1164 Bytes) Searching
> for 'strh', found strh' 0x6c-0xa3 (56 Bytes) VIDEO STREAM HEADER
> (strh):
>   fccStreamHandler='DIB '
>   dwStreamFlags=0
>   wPriority,wLanguage=0
>   dwStreamInitialFrames=0
>   dwStreamScale=1
>   dwStreamRate=7
>   dwStreamStart=0
>   dwStreamLength=2501
>   dwStreamSuggestedBufferSize=0
>   dwStreamQuality=-1
>   dwStreamSampleSize=0
> Searching for 'strf', found strf' 0xac-0x4d3 (1064 Bytes)
>   biSize=40
>   biWidth=2494
>   biHeight=1196
>   biPlanes=1
>   biBitCount=8
>   biCompression=0x0 '
>   Searching for 'indx', found strn' 0x4dc-0x4eb (16 Bytes) Discarded
> 'strn': Contents does not fit
> GUI.getMaxWindowBounds:
> java.awt.Rectangle[x=0,y=0,width=1600,height=1172]
> Skip JUNK: 0x4f4-0xfff (2828 Bytes)
> Searching for 'movi', found movi' 0x1008-0xbd02df33 (3171077932 Bytes)
> MOVIE DATA 0x100c-0xbd02df33 (3171077928 Bytes) (t=100 ms) Searching
> for stream 0: '00db' or '00dc' chunks
> 1 movie data '00db' 0x1014-0x2d9d13 (2985216 Bytes) (t=100 ms) .
> .
> .
> 1063 movie data '00db' 0xbcf71f44-0xbd24ac43 (2985216 Bytes) (t=9860
> ms) AVI HEADER (avih): (t=10 ms)
>   dwMicroSecPerFrame=142857
>   dwMaxBytesPerSec=0
>   dwReserved1=0
>   dwFlags=16
>   dwTotalFrames=2501
>   dwInitialFrames=0
>   dwStreams=1
>   dwSuggestedBufferSize=0
>   dwWidth=2494
> setKeyUp: 10
>   dwHeight=1196
> Searching for 'strl', found strl' 0x60-0x4eb (1164 Bytes) Searching
> for 'strh', found strh' 0x6c-0xa3 (56 Bytes) VIDEO STREAM HEADER
> (strh):
>   fccStreamHandler='DIB '
>   dwStreamFlags=0
>   wPriority,wLanguage=0
>   dwStreamInitialFrames=0
>   dwStreamScale=1
>   dwStreamRate=7
>   dwStreamStart=0
>   dwStreamLength=2501
>   dwStreamSuggestedBufferSize=0
>   dwStreamQuality=-1
>   dwStreamSampleSize=0
> Searching for 'strf', found strf' 0xac-0x4d3 (1064 Bytes)
>   biSize=40
>   biWidth=2494
>   biHeight=1196
>   biPlanes=1
>   biBitCount=8
>   biCompression=0x0 '
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html