Log in

View Full Version : Experimenting with motion blur


chilledinsanity
26th September 2007, 13:20
Hey, I'm trying to add motion blur to videogame footage (essentially 0 shutter speed) via an AVS script. With the game engine I'm using, I can output the footage it at any fps, though I don't want it insane. I want my final output to be 30fps, however I might record it at 150fps. What is a good way to achieve the blur?

I've tried just downsampling with TemporalSoften, but it leaves too much ghosting for my taste. I've also tried using MVFlowBlur and while I like the effect better, I only know how to use it adequately at 30fps, which means there's some extra ripples in the blur since it's doing more guesswork.

Is there a way I can use the motion vectors from the 150fps footage, but have it output at 30fps? And I don't mean simply select every 5th frame, that actually results in less blur since the difference between the frames at 150fps is less drastic.

wonkey_monkey
26th September 2007, 17:24
My experiments with blur suggest that a 100% motion blur doesn't look realistic - 50% is about right.

Off the top of my head, I'd recommend:

a) Use mvflowblur(blur=100...) on the 150fps footage, then average together the second, third, and fourth of every 5 frames (left as an exercise for the reader ;) ). You can adjust the numbers - i.e. record at 300fps, then average 3,4,5,6,7 from every 10.

b) Record at 60fps, use mvflowblur(blur=100), then selecteven.

David

chilledinsanity
26th September 2007, 17:55
I really do appreciate the advice, but for method a) do you think you could give me a little help with the syntax? Specifically, going from the blurred 150fps to averaging the frames? I wouldn't ask if I hadn't already spent a few hours already trying to figure this out (and before I even posted). Here's what I have so far, but making the jump from this to averaging the frames is where I'm having trouble:

source = avisource("C:\cp2\blur\ruins.avi").assumeFPS(150)
backward_vectors = source.MVAnalyse(isb = true, truemotion=true)
forward_vectors = source.MVAnalyse(isb = false, truemotion=true)
return source.MVFlowBlur(backward_vectors, forward_vectors, blur=100)

foxyshadis
26th September 2007, 19:29
TemporalSoften(1,255,255,50,2).SelectEvery(5,2)

Clouded's Average plugin would probably be slightly faster, but mvflowblur is so slow it won't make a difference.

chilledinsanity
26th September 2007, 23:27
Thanks foxyshadis, I didn't realize SelectEvery could average the frames as well. I'll look it up in the avisynth docs now so I know what I'm doing. Also it may be pretty slow, but believe me it's a LOT faster than the Twixtor or Reelsmart plugin for Premiere (which achieves similar results as this).

foxyshadis
27th September 2007, 01:55
TemporalSoften's doing the actual averaging - the first argument is the number of frames on each side to average with, the rest put it in a pure average mode, no limiting applied.

Alone it would average every frame with its neighbors, which is an interesting effect (often used for dreams and acid trips) but probably not what you want, so the selectevery fixes that. :p

The formula is basically: take temporal superresolution t and optionally a shutter length s. Create t times your output framerate initially. If you don't exactly care about s then apply 100% motion blur to each, then average enough frames to get roughly the s you want, then use selectevery to pick 1 of every t frames, returning it to the original desired framerate. It doesn't actually matter which frame you choose in the cycle, any's as good as another.

It only gets really complex if you don't line things up on whole frames, such as having a very specific s with the wrong t, but a little math and a lot of special-casing will see you through if you really need it.

Too bad there's no variant of mvflowblur that can take an arbitrary number of input frames and blur between them all.

chilledinsanity
27th September 2007, 18:29
Well thanks for your help with all this, I'm still experimenting, but I'm getting some of the best results I've seen anywhere with this, though I totally take back what I said about it not being really slow, it crawls like a bug stuck in glue, but it looks really nice. Here's the script I'm using if anyone else wants to try it, I've had good luck with 180fps:

LoadPlugin("C:\PROGRA~1\GORDIA~1\AviSynthPlugins\mvtools.dll")
avisource("C:\GCF\caps\hd180.avi")
source = avisource("C:\GCF\caps\hd180.avi").assumeFPS(180)
backward_vectors = source.MVAnalyse(isb = true, truemotion=true)
forward_vectors = source.MVAnalyse(isb = false, truemotion=true)
return source.MVFlowBlur(backward_vectors, forward_vectors, blur=100).TemporalSoften(1,255,255,50,2).selectevery(6,1)

blur of 100 might be a little overkill though, I may do some more experiments later, but it's a really smooth and natural motion blur with this script. It probably won't work as well with transparencies like a HUD as just averaging frames would, but it can handle very quick turns and fast motion without any ghosting.