Showing results for 
Search instead for 
Did you mean: 

How to calculate total time taken in video?

Go to solution

I want to calculate the time duration of  a avi file. I have tried to do using the elapsed The output I am getting is around 0.04s but manually if I calculate it, the video file lasts around 7s. I am confused why it is showing the wrong value.

PS:I have attached my vi below

0 Kudos
Message 1 of 6
Accepted by topic author enthusiast4

Try this, multiply the reciprocal of time between frames by totoal number of frames.




Untested, I have no codecs installed on this PC.

0 Kudos
Message 2 of 6

Thanks for the information. Now I can calculate the total time of an .avi file. For e.g if the video file stops at 13s in a media player,labVIEW displays the total time as 13.5 seconds. But, I guess LabVIEW shows the most accurate time

0 Kudos
Message 3 of 6

Can someone point out what's wrong with the 'read time between '. The time calculated for all avi files are same .I guess it is because of the 'frame and data to examine' indicator where the slider shows 0-165 which is fixed and it is not varying with different videos. For e.g if time taken by  video is of greater than 5.53s(shown on front panel),the video stops halfway on the front panel and if the time taken by video is lesser than 5.53s then the video starts playing again until the slider bar goes till 165.

Whats wrong with the VI? Isn'T 'frame and data to examine' shows the total number of frames in .avi file?


But,if I run the  'read AVI in labVIEW'.vi it is working fine i.e it shows different 'total time' for different videos.

0 Kudos
Message 4 of 6

Ok, to get accurate you probably want to reduce the number of frames by 2 since there's no delay before the first frame or after the last frame. 


Eg. 10 frames with 0.2s between frames is 8*0.2 = 1.6s and not 2s.


0 Kudos
Message 5 of 6

I tried reducing the no of frames, but that doesnt' work.It only makes the total time taken as 5.4s(without reducing 2 frames,time=5.3s). The main Problem is not the total time ,but the wrong estimation of total number of frames. No matter which .avi  file is played,it always displays 'total no of frames' to be 166 and 'Frames/sec' as 30. Therefore, the total time takes is always fixed (i.e 5.3s).

I can't find out why the total no of frames and frames/second values are constant. Any help will be highly appreciated.

0 Kudos
Message 6 of 6