LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

viewing AVI files

I've tried using the AVI viewing example that comes with Vision ("read avi example") but it views the AVI file very slowly - often slowing down to a frame rate of about 1/second.  All of the AVI viewing examples do this.  It doesn't matter which codec is used in the file or the frame resolution.  My CPU usage exceeds 50% at this point.  Uncompressed AVI files are viewed ALMOST at the correct frame rate with a CPU usage of about 25%.  Can anyone tell me what's going on?

 

I'm running Labview 2009 with the Vision Development module installed, on a dual core pentium with 4 gigs or ram.

 

I have no problem playing AVI files with other programs.

 

Thanks.

0 Kudos
Message 1 of 6
(3,399 Views)

Hi,

 

It takes time to read the images from the AVI file, maybe it is your hard drive that slows you down.

 

Here's a variation of the "read AVI example" that will load the whole AVI file into memory and then let you play it at the speed you want.

If the AVI files you need to read are not to big you can concider this and if you have very big AVI file then you'll have to do something in between the two with one loop that reads the images from the AVI file and put the images into a buffer and a second loop that displays the images at the correct rate.

 

Hope this helps


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 2 of 6
(3,369 Views)

 

Thanks for the reply.  I can play AVI files with other players without any problems, so I don't think it's the hard drive.  When playing AVIs, the cpu usage is very low, but when playing then with Labview the cpu usage is very high and the frame rate drops down to almost 2 frames per second no matter what vi I'm using.  Loading the whole AVI into memory is completely impractical and wouldn't solve the read problem. 

 

I've tried converting the AVIs to many different codecs but the problem is still the same.  Is there any way to specify which decompression codec IMAQ AVI Read Frame uses?   I'm wondering if it's just using an inefficient decoder instead of one of my other installed decoders like FFDShow. 

 

Splitting the reading process from the viewing / analysis process also wouldn't solve the problem since it seems to take about 15 seconds to read in 1 second of video anyway and it is overtaxing my cpu still. 

 

0 Kudos
Message 3 of 6
(3,348 Views)

Hi,

 

What is the expected frame rate of the AVI that you are trying to play? If you run the VI with the AVI files included with the LabVIEW shipping examples (lighter being ignited, crash test), do you still see frame rates that are this slow? There is a Wait function in the second frame of the stacked sequence structure that is meant to control the frame rate of the display. If you remove this Wait, does this increase the frame rate?

 

Another troubleshooting idea (or potential solution depending on your overall application) would be to see if the performance is improved when the VI is built into a stand alone executable. Running this as an executable rather than in the LabVIEW Development Environment may free up resources and improve performance.

 

Thanks,

 

 

Matt
NI Community Team
National Instruments
0 Kudos
Message 4 of 6
(3,325 Views)

@ratkindler1 wrote:

 

Thanks for the reply.  I can play AVI files with other players without any problems, so I don't think it's the hard drive.  When playing AVIs, the cpu usage is very low, but when playing then with Labview the cpu usage is very high and the frame rate drops down to almost 2 frames per second no matter what vi I'm using.  Loading the whole AVI into memory is completely impractical and wouldn't solve the read problem. 

 

I've tried converting the AVIs to many different codecs but the problem is still the same.  Is there any way to specify which decompression codec IMAQ AVI Read Frame uses?   I'm wondering if it's just using an inefficient decoder instead of one of my other installed decoders like FFDShow. 

 

Splitting the reading process from the viewing / analysis process also wouldn't solve the problem since it seems to take about 15 seconds to read in 1 second of video anyway and it is overtaxing my cpu still. 

 


You can always use ActiveX to read the AVI with whatever player you wish into LabVIEW but I don't think this would be a satisfying solution. I am surprised you can't get your AVI to play correctly in LabVIEW 😮

How did you create this AVI? Can you post it here or make it available somewhere?

 

Trying to help...


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 5 of 6
(3,298 Views)

Actually, playing the AVI is not the problem.  It's reading the AVI frames that's slow, even if I don't display them.  All AVI files have this issue no matter what the codec is.  All the AVI reading examples I've found have this problem for me.  If the entire AVI can be read into memory then it displays fine, but it would take something like 25 minutes to read in a 5 minute AVI and then play it.  I tried this already.

 

Ultimately I'm trying to do simple motion detection by frame subtraction but just reading the frames is so slow even if no other processing is being done.  It slows down to about 2-5 frames / second, and the computer is really cranking away.  If the AVI is uncompressed then it reads the frames at a usable rate of about 15 to 20 fps...just slower than the 29 fps frame rate of the video.

 

I haven't yet tried compling a vi and trying it on another computer yet.  I might do that tomorrow. 

 

How is the decoding codec chosen by Labview when reading AVI frames?  I'm still wondering if it's chosing the wrong one. 

0 Kudos
Message 6 of 6
(3,296 Views)