Log in

View Full Version : TimeStretch formula in docs


NoX1911
20th May 2007, 01:38
I try to play ntsc videos (23.976) on pal tv-out and search for a realtime fps conversion.

I found this in the docs:
TimeStretch(tempo = (100.0*25.0*1001.0)/24000.0)

But i dont understand it. I normally would do 25/23.976*100. Why 1001 and not 1000?

Edit:
Ok.. source fps is meant to be 24000/1001 (23.976fps) not 24fps. I thought film would be treated as exact 24fps.

setarip_old
20th May 2007, 02:03
Hi!

Have you "done the math" of both the formula in the docs and your own? ;>}

NoX1911
20th May 2007, 02:48
24000/1001 is a little more precise. But in the end they are nearly the same, right.

btw... you know whats wrong here?
directshowsource("video.avi")
assumefps(25)
AssumeSampleRate(Audiorate*((25*1001)/24000))

It remains at original samplerate... but should be 50050.

MessageClip(String(Audiorate)) shows 48000.

Edit:
Too much brackets... :)
AssumeSampleRate(Audiorate*(25*1001)/24000)

works!

Leak
20th May 2007, 10:24
btw... you know whats wrong here?
directshowsource("video.avi")
assumefps(25)
AssumeSampleRate(Audiorate*((25*1001)/24000))

It remains at original samplerate... but should be 50050.

MessageClip(String(Audiorate)) shows 48000.

Edit:
Too much brackets... :)
AssumeSampleRate(Audiorate*(25*1001)/24000)

works!
(25*1001)/24000 = 25025/24000 = 1
(25.0*1001.0)/24000.0 = 25025.0/24000.0 = 1.0427083333

See the difference? ;)

np: David Sylvian - Blackwater (Everything And Nothing)

IanB
20th May 2007, 12:47
Also you will possibly want Round/Floor/Ceil to convert the Float back to an Int for AssumeSampleRate()

Or you could short circuit the whole mess and get AssumeFPS(25, True) to appropriately fix the audiorate.

P.S. Also if you are trying to do this with WMV/ASF files in realtime you may have trouble with the stupid M$ ASF splitter enforcing the playback rate. This will cause very jerky playback.

NoX1911
20th May 2007, 18:38
(25*1001)/24000 = 25025/24000 = 1
(25.0*1001.0)/24000.0 = 25025.0/24000.0 = 1.0427083333

See the difference? ;)I tried float() but didn't manage to get any valid syntax. So, that's it finally... :)

Also you will possibly want Round/Floor/Ceil to convert the Float back to an Int for AssumeSampleRate()Is it really necessary? I would like to leave it as float. The more precise the better.... it think.
Correction: SampleRate must be Integer.
AssumeSampleRate(round(Audiorate*25.0*1001.0/24000.0))

Or you could short circuit the whole mess and get AssumeFPS(25, True) to appropriately fix the audiorate.I knew there is something like this somewhere... thx.