03-11-2024 06:04 PM
I am looking for advice on how to record an .AVI file that results in a file with accurate timing. I have arrived at posting this question after exhaustively searching and testing all example .vi's and relevant posts.
So far my experimentation has included:
I have a routine that applies vision processing to a frame. We would like to record an event that takes between 2 - 5 minutes typically, and we would like to be able to use a timing function to determine when the event occurs, to an accuracy of 1-2 seconds.
All the Windows video creators I have tried can do this easily, verified with a stopwatch. If I use the external apps and record for exactly 30 seconds, then myself or anyone else who opens the file and plays on say Windows Media Player sees a file that is 30 seconds long.
When I create a 30 second AVI using my VI, the resulting file is usually around 6 - 10 seconds long when played on Windows Media Player.
Is there any advice anyone can offer who has run into an issue trying to capture accurately timed .avi files?
Thanks!
03-12-2024 03:05 AM
It looks like you have lost frames in your 'Producer / Consumer architecture, or may be something wrong with FPS.
Usually it starts with snippet like this for initial check and proof:
This will produce exactly 30 seconds video:
And in the properties as well:
03-12-2024 01:00 PM
Hello, @Blocks. I (and others active in the Forum) have used IMAQdx to create AVI files at 30 fps and have seen AVI files with 120 frames last 4 seconds (120 frames/4 secs = 30 fps).
Why don't you attach the VI(s) that you are using to acquire the images and to write to the AVI file? I assume (but may I'm wrong) that you are using a Producer/Consumer design and have some reasonable confidence that you are actually recording and transmitting to the AVI Write routine all of the images (which probably requires allocating additional Image buffers so that the "next" image from the camera doesn't overwrite a previous buffer image that hasn't been written to the AVI yet).
When submitting your code, please note that some of the "old hands" with LabVIEW Vision might not have the latest version of LabVIEW. You should "Save for Previous Version", using LabVIEW 2019 or 2021, for example. Ideally, having all of the sub-VIs and TypeDefs are also a great help, though it might require a little work on your part to create a stand-alone "Demo" Project that just shows creating a 10" test AVI that we could easily try, verify, and (I hope) create an AVI file that runs at 30 fps for 10 seconds (after we find/fix the bug/misconception/problem you are experiencing).
Bob Schor
03-12-2024 03:01 PM
Hi Andrey,
Thank you so much for taking the time to respond and help me with this. I duplicated your vi and I did create an .avi exactly 30 seconds long with 900 frames.
Then I added a IMAQ Grab routine to the loop and a timer. My camera says it records at 30fps 3820 x 2160, but after experimenting with the frame rate input in the IMAQ AVI Create vi, I now believe it is really refreshing at 9fps.
When I use the 9fps value, I get an avi exactly 30sec long (obviously with 270 frames). Any other value causes the vi to take much longer than 30sec to record, or shorter produces an avi that is not 30sec long.
I attached my modified vi here for reference.
Thank you again for your input on this!