Login  Register

Re: Importing MOV Fails

Posted by Michael Schmid on Nov 30, 2018; 12:45pm
URL: http://imagej.273.s1.nabble.com/Importing-MOV-Fails-tp5021400p5021507.html

Hi Tony,

if the video is too large, you have to open it as a virtual stack. This
means that ImageJ loads only one stack slice into memory at a given
time, the rest remains on disk. This works only as long as you do not
modify the data; e.g. Analyze Particles works perfectly well.
As soon as you do any processing that modifies the pixels, you need all
the images in memory (or you have them as separate images in a
directory, and use Process>Batch>Macro to modify them).

If a virtual stack does not help and ImageJ can't open the uncompressed
movie into memory because it is too large, I see two solutions:
- (i) Taking only every n-th frame, as you suggested
- (ii) Alternatively, if there is a simple preprocessing step that is
the same for all slices, and you know Java processing, you could write a
plugin that creates a virtual stack by taking the image from another
virtual stack, does the processing ("on the fly") and thereby creates
the current slice of a new Virtual Stack.

For (i), taking every n-th frame:
In principle, you could try opening the movie as vitual stack and then
use Image>Adjust Size to set the desired number of frames. Use
Interpolation:None and deselect "Average when downsizing".
It is a very slow command, however; downsizing a 100 GB stack would
probably need several hours (The reason is that it prepares everything
for interpolation, even if it does not interpolate).
A faster version is opening the movie as virtual stack and running this
macro:

   // subsample stack
   n = 20;  //every nth slice will be kept
   for (i=nSlices; i>=1; i--)
     if (i%n != 1) {
       setSlice(i);
       run("Delete Slice");
     }

(It is still slower than it should be because of the flickering display;
setBatchMode(true) unfortunately does not prevent it).
Then duplicate the stack to read it into memory.

Alternatively, you could play with the ffmpeg options; maybe adding
something like the following works:
   -filter:v select="mod(n-1\,20)"
If it does not work on the input movie, you could also try it on the avi.

--
By the way, you could also try opening the MOV directly with Quicktime.
According to reports of others, this is what you need (I have not tried
myself):

     ImageJ running with 32 bit Java
     QuickTime and QuickTimeJava installed
     A copy of QTJava.zip in the jre\lib\ext directory of the 32-bit java

Then, BioFormats should directly open MOV files. But again, you have
only the two possibilities of either having a Virtual Stack or it will
be too large. Maybe your plugin works with the Virtual Stack created by
BioFormats, but it if it does not work with that of an AVI opened by
plain ImageJ, it is rather unlikely.


Michael
________________________________________________________________
On 26.11.18 16:39, Anthony Andriano wrote:

> Thank you for the information and I'm very sorry for the incredibly late
> reply. I've been traveling quite a bit and didn't have time to sit down
> to try this.
>
> I tried two things:
>
> I converted to mp4, which worked without any issues using ffmpeg as far
> as I can tell. However, imagej still won't import the video. The
> Bio-Formats options menu opens and Hyperstack is pre-selected (I've
> tried every option without success). After hitting ok, I get an error
> that says "File not in supported format, a reader plugin is not
> available, or it was not found." I then turned on the ffmpeg plugin,
> which allowed the video to be imported as a virtual stack, but I
> couldn't figure out how to do anything with it at that point. The
> tracking plugin, which is ultimately what I need to use, said no images
> were loaded.
>
> Then I tried your suggestion, which is what I initially requested:
> converting to uncompressed video. That seems to work, but, as you said,
> the videos become extremely large and unwieldy. The videos were created
> at 30 FPS, but I only need 1 or 2 FPS at most for my purposes. I've been
> trying to remove the other 28 or 29 frames from each second of video
> without success. Imagej doesn't like the uncompressed files since they
> are nearly 100 GB.
>
> Any advice would be greatly appreciated.
>
> Thanks,
> Tony
>
> On Mon, Nov 5, 2018 at 11:30 AM Michael Schmid wrote:
>
>     Hi Tony,
>
>     your Video is H264 compressed; changing to some other container (like
>     AVI) alone does not help.
>     I use plain ImageJ, not Fiji, so I don't know whether File>Import>Movie
>     (FFMPEG) can do it, but I think it should. If you don't have it use the
>     update site. See
>     https://imagej.net/Video
>
>     If not, you can convert it to uncompressed AVI, e.g.
>
>     ffmpeg -i 'IMG_2472.MOV' -pix_fmt nv12 -f avi -vcodec rawvideo
>     IMG_2472.avi
>
>     The uncompressed movie file can be read by plain ImageJ, but it will be
>     about two orders of magnitude lager than the H264-compressed version.
>
>
>     Michael
>     ________________________________________________________________
>     On 03.11.18 02:57, Anthony Andriano wrote:
>      > Hello,
>      >
>      > I've been trying to import an MOV video into ImageJ (Fiji) for
>     several
>      > hours without success. I've tried the Quicktime plugin, 32 and 64 bit
>      > ImageJ, converting to AVI/MP4/MJPEG and many other formats, but
>     nothing
>      > I've tried has worked. The reported error is either something
>     along the
>      > lines of 'Unsupported' or what looks like a stack dump from JRE.
>      >
>      > I've been successfully using a camera that outputs videos with the
>      > following attributes (found via GSpot 2.70a):
>      >
>      >     - AVI v1.0
>      >     - Codec c,S: DIB (_RGB)
>      >     - Codec Name: BI_RGB Raw Bitmap
>      >
>      > My new camera can't output that format apparently, so I'm trying
>     to convert
>      > an MOV, which it can output easily, into a format ImageJ (Fiji) will
>      > understand and accept. I uploaded my video here if anyone wants
>     to take a
>      > look: https://www.dropbox.com/s/nndt0ye8k2c61sm/IMG_2472.MOV?dl=0
>      >
>      > If anyone has any ideas, I would greatly appreciate help with this.
>      >
>      > Thanks,
>      > Tony
>      >
>
>     --
>     ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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