LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AVI read frame : 30 first frames are slow

Hi Forum,

I am working on a video analysis algorithm that needs to process frames from an avi movie file. I implemented a very simple VI that loads a frame from the AVI movie. To do that, I use "AVI read frame.VI". Then, I read all frames of the movie in order to process them. The Vi works fine, I can get the frames I want. However, there is a problem with the execution speed of the VI.

During the 30 (approx.) first frames the loading time of the frame is very slow. It varies between 40ms and 200ms. Then, the speed stays until the end of the movie around 35-40 ms.

40 ms for the loading time of a frame is OK for me, however, I want to avoid longer loading times. One possibility I could have is not to use the ~30 first frames from processing, but I would rather try to avoid such a solution.

Has anyone already seen this problem before and can help me on this ?

Thanks a lot.

Laurent
0 Kudos
Message 1 of 7
(5,447 Views)
Hi Laurent,

I will have a look at this Forum IMAQ: acquire 5000 or more frames, save and read to AVI and this knowledgebase High CPU Utilization in Vision AVI Playback

Best regard,
Nick_CH
Message 2 of 7
(5,427 Views)

We have large AVI files that we post process.  Right now that processing is very slow, about 130msec per frame.  Since our AVI's may be thousands of frames long, the processing takes way longer than we'd like.

 

When we eliminate the processing and just read each frame of the AVI file, it takes about 90msec just for the IMAQ AVI Read Frame.vi to execute.  According to the knowledge base link that Nick_CH provided, the slowness of IMAQ AVI Read Frame.vi is due to the CPU having to do the work usually done by the graphics CPU to display the image on the PC monitor. 

 

In our case, we don't need to display the images on the monitor during post processing, we just need to run intensity calculations on the AVI images.  Is there any way we can speed up the AVI frame reading during our post processing?

 

Hans 

0 Kudos
Message 3 of 7
(5,169 Views)

Hi Laurent and Hans,

 

your problem seems highly related to the codec you are using for video compression/decompression.

Uncompressed is not always the best mehod. Try e.g. the huffYUF Codec. This one is very fast.

 

Greets Christian

0 Kudos
Message 4 of 7
(5,150 Views)

One correction to my prior post - for longer AVIs, I'm seeing AVI frame read times that average about 30 msec.

 

Hmm... We are using uncompressed AVIs since we do not want any compression losses and since we don't want delays when writing frames.   At first it is counterintuitive that it would take longer to read an uncompressed AVI frame than to read and uncompress a compressed AVI frame.  It does make sense that it would take longer to transfer an uncompressed and hence bigger frame from a hard drive, but it's surprising that it should take about 30 msec to read 1.4Mbytes from disk.  

 

Then again, for a 7200rpm  hard drive read rate of about 480Mbit/sec = 60 Mbyte/sec you'd expect a read time of 1.4/60 seconds = 23 msec, so Christian you may well be correct - the main factor on AVI frame read times could be hard drive transfer time which would be reduced for smaller compressed files.

 

Another clue that hard drive transfer time is the key is that when I loop thru my AVI reading the frames one after the other, my CPU usage is only about 10%. 

 

Hans 

 

 

0 Kudos
Message 5 of 7
(5,121 Views)

Hi hans17,

 

Sorry to dig this thread up (and duplicate post by the way) but I am having difficulties when reading AVIs of 2000 images only. I get a CPU load error.

 

How do you manage to read multiple thousands images? The Read AVI example failed to open mine... I am starting to think that it may be a codec error.

 

Thanks

Christophe

 

 

 

0 Kudos
Message 6 of 7
(4,837 Views)

Hi Christophe,

 

We were just reading the AVI one frame at a time into the same image reference.  We write the AVIs one frame at a time, then read and process one frame at a time.  If you can't do that it could be a codec problem.  You could try a different codec, or uncompressed.

 

Hans

0 Kudos
Message 7 of 7
(4,824 Views)