Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Corrupt AVI files if my LV app is killed

So I have discovered that if my LV application (LV2011-64bit & Vision Dev Module 2011) crashes while it is in the middle of writing to a frame to an AVI file, the entire AVI file becomes corrupted.  This also occurs if the power is cut to the PC, or if the EXE is killed from Windows Task Manager.

 

This is a problem because I am constantly writing frames to my AVI file.  So my data is at risk of being lost.

 

Interestingly enough, this does not appear to happen to TDMS files if they are ungracefully closed.  So I will probably switch to storing my image frames in a TDMS.

 

But that is a lot of programming effort to change my code.

 

Anybody have any workarounds to avoid my AVI files being corrupted?

http://www.medicollector.com
0 Kudos
Message 1 of 4
(3,213 Views)

Hi josborne,

 

I'm not sure there would be a direct workound for this, as the "ungraceful" closing leaves all sorts of references open. Is it necessary for your data to all be part of a single AVI file? Why not just have the program save every X number of frames if crashing is a concern?

Matt J - NI Tools Network
0 Kudos
Message 2 of 4
(3,207 Views)

I'm not sure if AVI files have any mechanism to gracefully support opening files that haven't been gracefully closed. For instance, the header of the file includes the size of the following data, so it must be updated for the file to be "valid". Updating the header after every frame would be woefully inefficent, so it doesn't make sense to do that. I don't know offhand about the TDMS format but my assumption is that it doesn't require updating the header every time new rows of data are added.

 

Now, you could probably try to make accomodations for the program closing unexpectedly, such as having a standalone process writing data to disk and getting the images send via some inter-process communication mechanism like shared variables or TCP. However, this would not solve the problem of the whole computer losing power, for instance.


Eric

 

Message 3 of 4
(3,204 Views)

Yeah, I guess I am not too surprised the file gets corrupted.  Though I am impressed that TDMS files are actually NOT corrupted (kudos to your developers!).

 

Thanks for the tip on using smaller file sizes.  I guess I have two work arounds now:

 

1.  Split the files into smaller chunks so I don't lose too much data if it crashes.

2.  Change to use TDMS files to store the images.

 

Thanks!

 

 

http://www.medicollector.com
0 Kudos
Message 4 of 4
(3,202 Views)