View Full Version : Motion: How is it calculated?
NiTroGen
16th September 2002, 22:21
There is motion value in the statistics section of "Nandub files" tab. How is this value calculated? I know it has to do with the keyblocks of a frame and the Span & Sensitivity parametres. Can anyone describe me the way to calculate the motion value, step-by-step, using the three parametres I mentioned above (or any other parametres needed)?
TheWEF
16th September 2002, 22:41
Nandub Options Explained (http://mitglied.lycos.de/koepi/)
NiTroGen
16th September 2002, 22:51
I already read it (again and again) before making this post, but I didn't understand the exact way of calculating it. :( Maybe my IQ level is a little low right now (because of the examination session at the university).
Can someone explain the motion calculation algorythm. Please..... :D
TheWEF
17th September 2002, 00:39
example:
span = 3
sensitivity = 10
frame 1: 5 keyblocks
frame 2: 8 keyblocks
frame 3: 15 keyblocks
frame 4: 10 keyblocks
frame 5: 3 keyblocks
frame 6: 0 keyblocks
frame 7: 2 keyblocks
this is how you calculate motion for frame 4:
(
1*5+
2*8+
3*10+
7*10+ {not 15, because 10 is the max!)
6*3+
5*0+
4*2
)*299/(10*(1+2+3+4+5+6+7)) =
(5+16+30+70+18+0+8)*299/280 = ~ 157
the frames that lie ahead are more important than the ones that lie behind.
ok?
wef.
NiTroGen
17th September 2002, 15:59
So, If I got this right... With a span of 4 and a sensitivity of 8 that would be:
span = 4
sensitivity = 8
frame 1: 5 keyblocks
frame 2: 8 keyblocks
frame 3: 15 keyblocks
frame 4: 10 keyblocks
frame 5: 3 keyblocks
frame 6: 0 keyblocks
frame 7: 2 keyblocks
frame 8: 4 keyblocks
frame 9: 6 keyblocks
calculating motion for frame 5:
(1*5 + 2*8 + 3*8 + 4*8 + 9*3 + 8*0 + 7*2 + 6*4 + 5*6)*299 /
/ (8*(1+2+3+4+5+6+7+8+9)) = ...
Is that correct?
Do we take into account the keyframes or just the delta frames? And what do you think are the optimal settings for span and sensitivity? Do they depend on something? Oh, and what about the first 3 or the last 3 frames of your example. They are ignored or is the span reduced?
TheWEF
17th September 2002, 22:27
Originally posted by NiTroGen
Is that correct?
yes.
Originally posted by NiTroGen
Do we take into account the keyframes or just the delta frames?
only keyframes.
Originally posted by NiTroGen
And what do you think are the optimal settings for span and sensitivity?
gknot default is 15,15. theoretically the optimal settings depend on the number of macroblocks you have in a frame (=resolution).
the algo was invented by nando. it's not easy to define what 'motion' really is. when you compare the motion curve in gknot to what's going on in a scene i think the numbers give quite a good representation of 'motion' in the movie. of course you could question the whole approach and come up with a better algo...
Originally posted by NiTroGen
Oh, and what about the first 3 or the last 3 frames of your example. They are ignored or is the span reduced?
i don't know about the exact implementation in nandub. we're talking about a couple of frames in the beginning and end of a movie...
i slightly modified the algo in gknot and called it 'scene separated motion detection'. in nandub motion is a continuous curve from beginning to end. in gknot motion is calculated for each scene separately (look at the graph in gknot).
very often in action movies there might be a cut from an action scene to a still shot and back and so on.
in nadub you get high motion values for the first couple of frames in the still scene (the one's that lie within the span). motion is kind of overlapping.
in gknot i implemented this:
e.g.:
frame 101:8 keyblocks.
frame 102:9
frame 103:12
frame 104:7
frame 105:8
frame 106:85
frame 107:1
frame 108:0
frame 109:0
here frame 106 is the first frame of a new scene.
in gknot the frames on the other side of a scenechange are not taken into account (the values are replaced with the last value in the scene).
calulating motion for frame 103 i set:
frame 101:8
frame 102:9
frame 103:12
frame 104:7
frame 105:8
frame 106:8
frame 107:8
frame 108:8
frame 109:8
calulating motion for frame 108 i set:
frame 101:1
frame 102:1
frame 103:1
frame 104:1
frame 105:1
frame 106:1
frame 107:0
frame 108:0
frame 109:0
then calculate with nando's algo.
gknot's motion values are stored in the ecf-file and therefor can be used in nandub.
well, look at the graph in gknot and in nandub and you'll see what i'm talking about...
wef.
NiTroGen
19th September 2002, 22:33
Thanks a lot for your answers. You told me exactly what I wanted to know.
Just a final question... I'm trying to make an automatic selection for span and sensitivity values. Span is really difficult to find automatically, but since sensitivity depends on the number of total macroblocks, what do you think is the optimal percentage of total macroblocks to set as sensitivity value?
For example, most of my encodings have a resolution of 512x288 (576 macroblocks) or 512x208 (416 macroblocks). Do you think a 3% of the total macroblocks is enough to set for the sensitivity value? (That's 17 or 12 ). Should it be raised or lowered?
TheWEF
20th September 2002, 00:08
Originally posted by NiTroGen
...what do you think is the optimal percentage of total macroblocks to set as sensitivity value?...
what can i say ? i guess it depends a lot on what you finally want to do with those motion values you calculate. i wrote my own algo for motion-based bit(rate) redistribution in gknot. and i'm sure the "best" settings depend a lot on the movie itself.
some people even think that the whole idea of giving high-motion scenes less bitrate is nonsense and in some cases that's definitely true. if a movie often has scenes with a moving background e.g. people sitting in a car or something, the foreground (faces) suffers from the lower bitrate.
it's still my opinion that in most cases motion modulated bitrate will improve overall subjective 'watching'-quality, but i also know that it's not always true.
at the moment there is no algo available to calcutale the "best" settings. you have to test and test and check with your eyes...
wef.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.