ImageJ macro only imports the first 904 frames of an avi file

I am trying to import avi files to ImageJ to be able to process them.
To open the file I use the

open("");

command, to be able to select the file I want. However, the avi imported has a maximum number of frames of 904, i.e. any file longer than this will be truncated to 904. Files smaller than this are loaded correctly.

When I manually import it (File>Import>AVI) the full number of frames is loaded.


Above is the file imported via the macro.


Above is the file imported manually.

Thanks in advance for any advice on how to solve this.

It looks like the truncated file was not opened as a virtual stack. It is missing the " (V)" in the title bar. The open(filePath) macro function opens AVI files by default as virtual stacks. When using File>Open and File>Import>AVI you need to check “Use virtual stack” in the dialog box.