Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Compressing avi files

Hello,

I wondered if someone might be able to advise me on my options for compressing my .avi files to a more managable size.  The application i want to use this code for will invovle recording an activity that will take up to 60 minutes.  I will then likely have to spend many hours trawling through these, stopping, rewinding, fast-forwarding, etc.

I have experimented with a couple of the compression filters:  'MJPEG Compressor' doesn't seem to reduce the file size by much, although 'Indeo video 5.10 Compressor' does seem to be very effective.  The problem with that is when I play the resulting file in media player, as well as reducing the file size it has also compressed 1 minutes worth of footage in to about 15 secs.  Does this mean i need to do something to decompress the file before i view it?

I have my cameras set to 15 fps, and in 'IMAQ AVI Create' i have made sure that it creates at 15 fps, reduced the 'max data' down to 5000 and the 'quality' always seems to default to -1, even when i'm not using a filter.  I can reduce the cameras to 7.5 fps in MAX, but for some reason the input to the 'IMAQ AVI Create' doesn't like me using a non-integer.

Could you please advise me:  What are my options for reducing the file size, in a way that will not cause too much hassle when i want to sit and analyse the recordings?

Best regards,

Bruce

0 Kudos
Message 1 of 14
(6,167 Views)
Hi Bruce,
 
Saw your other post and then this one.  Below is a list of the filter names I have (I found this by using the IMAQ AVI Get Filter Names.vi)  Different programs do give exposure to different codecs.
 
DV Video Encoder
Indeo® video 5.10 Compression Filter
MJPEG Compressor
Cinepak Codec by Radius
Intel Indeo(R) Video R3.2
Intel Indeo® Video 4.5
Indeo® video 5.10
Intel IYUV codec
Microsoft RLE
Microsoft Video 1
I also found that Indeo seemed the best one.  Now with your program how often do you actually take an image of the objects?  (try placing a milisecond counter and see how many miliseconds there are between each image on average)  You may find that the images are being sampled at a higher rate then the one you have set in MAX.
 
Your program will tell the cameras to sample at the quickest rate they can in their current setting.  You may need to add a delay to the while loop (or make it a timed while loop) and set the delay to 1/15th of a second (66ms) then you should get the results are looking for?
(assuming you set the AVI to record at 15 fps)
 
Give that a go?
 
AdamB
 
Applications Engineering Team Leader | National Instruments | UK & Ireland
Message 2 of 14
(6,164 Views)

Hi Adam,

Thanks for that, I'll give it a shot this morning and report back.

Cheers

Bruce

0 Kudos
Message 3 of 14
(6,149 Views)

Hi Adam,

 

I’ve tried replacing the while loop with a timed while loop (set with a period of 66ms, priority 100, and source 1kHz) and the result is pretty much the same – 1 minute’s footage played back over 15secs.

 

So, where do I find a millisecond counter?  Where do I put it when I find one?  And what exactly is it that I’m looking for?

 

When you said “the images are being sampled at a higher rate then the one you have set in MAX”…….which setting should I be looking at in MAX?  Or are you just referring to the video mode?  Anyway, my settings are:

 

Video Mode:  640x480 (Mono 😎 15.00fps

Speed:  200Mb

Timeout: 5000ms

 

In MAX, under the Camera Attributes tab, there is an option for frame rate which is set to ‘Manual (Relative)’ with a value of 0.  Is this anything to do with the problem?

 

Apologies again for my lack of basic Labview knowledge!

 

Thanks

 

Bruce

0 Kudos
Message 4 of 14
(6,144 Views)
Hi Bruce,
 
Well the code you have sent looks like it would work fine.
If you delete frames per second input from the avi init.vi and right click that node and select create constant. Change this to 15.. it may have been a conversion error that caused the problem (you have a coersion dot there)
 
Other than that.. I have tried the code and it runs OK (with my change and before)
what player are you using?
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
Message 5 of 14
(6,142 Views)

Whoops, I guess that smaple file was too big to be uploaded.

Bruce

0 Kudos
Message 6 of 14
(6,131 Views)

Hi Adam,

Sorry about that last message - i tried to upload an example of one of the .avi files i've created for you to have a look at, but it must have been too big to upload.

Anyway, i had a shot at making the change you suggested: removing the frames per second input to the avi_create.vi (which i thought i had assigned as a constant), and replacing it with a new constant containing "15" - with no decimal point.  I still got the same result.  Also, what did you mean by a "coersion dot"?

When you say you ran the code and it worked, do you mean that you got it to record for, say 1 minute, and then play back for exactly the same amount of time (1 minute)?  If you did, does that not mean that the code is working fine, and therefore there must be some problem with the way i've got my cameras set up in MAX?

I have been playing the files in windows media player, and with nero showtime, both of which give the same result.  Do you think it could be the player(s) that are the problem?

Thanks again for your help - hopefully i'll get this thing working soon!

Bruce

0 Kudos
Message 7 of 14
(6,118 Views)

Hi Bruce,

Yes it does indeed work on my computer so the code is fine.  The fact that it's not working on your machine could be a number of things.

Your computer could be too slow to record at that rate and therefore is only recording a frame once or twice a second (meaning that when it plays back you will get very quick playbacks)

The cameras could be set up incorrectly but the grab setup should be fine the way you have done it.

I would like you to try putting the period of the timed loop as 1000ms and the framerate of the AVI record as 1 frame pser second.

If this works then it's the speed of the computer that is the problem.  They're aren't many ways around this as the computer is having to do a lot of processing each frame. (get size, change size of final image, place one image in final, place second image in final, then record frame to AVI (but convert the frame to Indeo format in the process)

My computer is a Dual core 2.13GHz with 2Gb of DDRRAM so I'm guessing it's pretty quick and this still has a few issues at 15fps.

Give the 1000ms period a go and get back to us?

Thanx

AdamB

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 8 of 14
(6,105 Views)

Hi Adam,

Yeah, sounds like that might be the root of the problem.  The machine has "AMD Athlon 64x2 Dual Core Processor 4800+ 984MHz, 2.00GB RAM".......see the attached screen shot, just in case i've misinterpreted the details.

I tried 1000ms at 1fps and it was fine.  I tried a few other values, and through an iterative process found that 250ms at 4fps is probably the best i'm going to get.

I take it there's nothing else i can do?  Should i just accept that the 4fps is the best i'm going to get?  I'll maybe try going back to writing them as 2 different .avi's simultaneously and then concentrate ways of playing them back at the same time?

Let me know what you think

0 Kudos
Message 9 of 14
(6,102 Views)

Hmmm,

(Yeah my computer wasn't doing the combining of the images (as I only have one firewire camera at the moment))

Well we could 2 things! We could keep the joining of the images but write the file uncompressed.  Then later on you could compress the file offline.

(like so)

 

OR

you could try saving them simultaniously (I think this wouldn't work as 2 simultanious access to the HDD would be slow) without either encoding or combining them and THEN adding them together and encoding in another vi?

Sorry but that's all I can think of at the moment.  It does seem to be a processor power problem so I'm at a loss as what to do.

AdamB

Message Edited by AdamB on 11-09-2006 08:22 AM

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 10 of 14
(6,102 Views)