Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Pro Tip: Get AVI Animation Length, Video Duration

Author
Message
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 10th Jun 2018 21:27
Get the duration of an AVI animation. No need to manually play the animation out and try to detect when it is no longer animating.

Back Story:
I have about 3500 video files and it would have taken about 23 days to have the program manually play each one and measure the lengths so they could be stored and later used. So rather than do that and since there appears to be no documented command to get this information, I found an AVI format spec sheet and whipped up a small function to read the duration from the file. No need to wait, saved myself nearly a month.

Open an AVI file and extract the duration:



See my previous tip here...
https://forum.thegamecreators.com/thread/220759
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 11th Jun 2018 23:51

Great tip, Mage!
Do you think there's a way to also get the current frame number in real-time as the video is playing?
Send your parents to noisy sprite demo hell... enter the D-Zone
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 12th Jun 2018 05:19
Kind of. That is not stored in the file.
You could instead extract the frame count and frame delay (as this code snippet does) and calculate the current frame number based on how long the animation has been playing. This would give you an approximate frame number.

The AVI is played using the codec system in windows, so it really is isolated from the rest of the program and this limits what control you have over it. For example I have attempted to seek/skip parts of animation but this seems to be impossible in DBP. So I instead attempted to have the animation speed up so I could fast forward to a section I wanted to skip to, but this was also impossible. The command didn't work. Then I looked at the Dark Video Plugin, where these things are possible if you want to re-encode all AVI files into their Dark Video format. I don't that sucks. You'd have larger files with loss of detail.




Login to post a reply

Server time is: 2024-04-20 08:33:13
Your offset time is: 2024-04-20 08:33:13