Rebuilding bad frames using OFlow

Written by Rich Frazer on .

The original version of this article (with video) can be viewed here


This is a tool I recently built for helping fix footage that was shot on an octocopter. However, it could equally be used for any situation where you have footage that has good frames interspersed with bad frames i.e. a CG render that broke on the farm.
In this case the problem was that the octocopter suffered from intermittent vibrations, causing the footage to become blurred every few frames. I found myself going through and fixing the blurry frames one at a time, which became hugely time consuming and called for a more automated method.


OFlow is a great tool at creating new frames based on morphing between two existing ones. This would normally be done when retiming – i.e. if slowing footage down to 50% speed, then a 100 frame clip would become 200 frames long, and the alternate missing frames would be rebuilt by OFlow.

This is easy to calculate if applying a uniform retime over an entire clip, but I needed a way of arbitrarily telling OFlow which frames to keep and which to rebuild without actually retiming anything.

The solution was to first establish which frames were good. In my gizmo I created the “Frame” input, and then went through and created a keyframe on every frame that was to be kept.

Then I added a Python Button that runs a little ‘Rebuild’ script. Basically, a TimeWarp node is fed the frame numbers of the good frames, and the non-keyframed frames (i.e. the blurry ones) are skipped. So in this case, the first keyframe occurs on frame 100 and is copied into frame 1 of the TimeWarp. The eighth keyframe occurs on frame 115 and is copied into frame 8 of the TimeWarp, and so on.

Next, an OFlow node inverts this process – retiming the TimeWarp’s output back to normal speed, and using optical flow to rebuild the skipped frames.

I dropped a couple more buttons on the gizmo to help speed up the process as much as possible, but really the most time consuming part is manually going through and keyframing your good frames – after that OFlow does all the heavy lifting.


Here is the GitHub link for the node – just select the text, copy it then, then paste it into Nuke.


0 # Cory Pelligreno 2015-05-17 01:12
Thank you very much for sharing. This is very handy, and processes much quicker than I anticipated.
+1 # Steve Lambert 2015-06-19 11:47
Hi there, thanks so much for this script, It's exactly what I needed - but having a problem... when I run this script i get :

# Result:
File "", line 1
Group {
SyntaxError: invalid syntax

what version of nuke are you running? I'm fairly new to nuke, so It's probably operator error :P (running 8.0v4)
0 # Listis Car 2015-07-14 04:30
Thanks for sharing, this is a common problem we encounter.
+1 # Spencer Tweed 2015-08-06 17:20
Good idea! Unfortunately though it creates a performance hit because everything gets piped through that oflow (which is generating vectors weather you need them or not). Why don't you put an expression on that switch node so that it only reads the oflow on the bad frames? That could theoretically optimize this group quite a bit.

- Spencer
+1 # Spencer Tweed 2015-08-06 17:59
Ok I took a whack at it and fork'd your github post!

- Spencer
0 # tibo g 2015-12-27 23:38
Merci !
Un grand merci :)
Je fesais cela à la main ... le Gizmo fait très bien le travail.
C'est super
0 # darren coombes 2022-01-20 05:13
has anyone got this working on nuke 13 ?
0 # s v 2022-07-31 19:59
works on 13.1v2

You have no rights to post comments

We have 2621 guests and 42 members online