Blender 2.8 2D video stabilization tutorial


hey guys welcome back to another blender
2.8 tutorial and today I’m gonna be showing you how to do two-dimensional
video stabilisation all inside of blender without any add-ons necessary so for
example I have this video right here I got it from a free stock footage website
I’m gonna put the link in the description but I have some footage of I
guess their cookies being glazed or something something to do with baking
but more importantly you see that there’s a lot of camera shake going on
so in terms of the camera position it’s moving everywhere in terms of rotation
there’s a bit of tilt if you look very closely there’s a bit of camera rotation
and then for camera scaling which is zooming in and out we don’t really have
this issue but the technique I’m going to show you for stabilization is going
to fix this camera shake in terms of position rotation and scale for the 2d
case so let’s take this stock footage and bring it into blender 2.8 so we’re
gonna open up blender it’s gonna open up into our 3d viewport of course we don’t
need any of this because we’re just dealing with videos we’re not dealing
with any 3d objects like this so when you have blender open I’m just gonna go
here and change from 3d viewport over to movie clip editor and this is where
we’re gonna be doing 99% of our work so once you’re inside the movie clip editor
I’m just gonna open and then just import in our footage for me that’s the desktop
and then stock footage so it’s gonna load in right here and the first thing
you’re gonna notice is you have this window right here with all the
information and we can toggle this in and out with n so just hit N and we have
all this information so for example this is 1080p footage let me make this a bit
bigger it’s 30 frames per second and there are 272 frames for this video so
the first thing I want to focus on is this frame rate 30 frames per second we
want this to match with blenders frame rate so to make this happen go to the
output tab right here and then in your frame rate just click this drop down and
in my case it’s 30 frames per second yours might be 24 or 60 but just change
it to the relevant one and if yours does not show up on this list and it’s a
weird number with a decimal like thirty point five you’re gonna want to go over
to custom but when you type in thirty point five with a base of one you’re
going to notice that it rounds up or down in this case around it rounded up to 31 so to prevent this if we want thirty point five we’re just gonna scale
everything by ten so thirty point five turns into three hundred and five and
then one turns into ten so essentially what we’re doing is dividing dividing
these two numbers so three hundred and five divided by 10 gives us our thirty
point five so for 30 frames per second we can either do three hundred over ten
or just you know 30 over one which is default so we’re gonna do 30 frames per
second okay second thing is that you see that this
is two hundred and seventy two frames long but our blender project is only 250
frames long so this video is longer than this project I mean easy fix you can
change this to 272 but if you don’t want to do that I’m just gonna change it back
there is a button that automates this and that is set scene frames and you see
it automatically turned this to 272 when we clicked it so in this case we’d be
stabilizing this whole footage but for the sake of this tutorial I’m only gonna
do the first hundred 50 frames or so so now I’m when we looking at this video
for the first hundred and fifty frames and it’s not like doing the whole thing
would be any different this is just so everything loads faster and talking
about loading faster you see if we take our play header and move it down we have
some very very choppy footage it’s not loading very quickly at all even if you
have a good computer it should um it should have this issue so we’re gonna go
over to the first frame so shift and then left arrow to do that and we want
to solve this issue and you can either play the video shift spacebar for me for
you might be alt spacebar for play so you see as we play we get this purple
line which means basically this part of the footage is good so you can either
play all of this footage out and then it’s gonna load into memory or just hit
prefetch right here and it’s gonna do that automatically for you okay so now
all this videos in memory you might still have to play over parts of it to
get it loaded but generally this is going to be a lot better so you see now
we have some smooth motion and this is very useful for when we’re going back
and forth for stabilizing so for stabilization the main idea is we’re
gonna pick a point on this footage let’s say we pick you know this point right
here we’re gonna track it along the footage so as
this moves to the right the tracker will also move to the right with the footage
and then once we have all our tracker data we’re gonna use that to stabilize
so if this goes up we’re gonna correct it by moving the footage down and that
you know stabilizes the position and we also have ways to deal with rotation and
scale so what tracker do we want to use well we want a point that stays the same
throughout this whole footage so if I put a point on this brush it doesn’t
work because the brush is moving around everywhere plus we don’t want to
stabilize to the brush or this footage is gonna be moving everywhere
so some contenders are you know some spots on the cookies we have this kind
of dark area right here which would be good just look for a high contrast spot
the reason I’m not gonna pick this one right here for now
is because it’s on the boundary of our video and we want to stabilize to
something near the center because that’s where the viewers attention is going to
be so I think there is an obvious candidate and it is the spot right here
so I’m gonna go back to the first frame shift and then left arrow to do that and
then we are gonna add a tracker so to add a tracker there’s a bunch of ways
but the fastest is to hold ctrl and then click so ctrl click puts a tracker and
we can change over to the tracking window right here and that’s going to
give us some tracker information you see we have this view right here which lets
us move it and we’re also gonna save our project cuz I haven’t done that yet so
control us desktop and I’m gonna call this stable not with caps stabilized
just so we don’t lose any progress if we have a crash not that we should have a
crash but what we need to do now is track this feature along the video but I
want to talk about how this tracker works a bit before we do that so we have
this little box right here which says what are we looking at if I scale this
up with s you see it changes here too so now we’re looking at this whole area we
can rotate it with our move it with G same as usual
so I’m just gonna scale it down with s just so we only have this dot and then
we need a second bounding square so you can hit alt s to show that that’s alt s
or just go to you clip display and enable search and that’s going to give
you this box which we can also make bigger and smaller and the way this
works is basically again this box says what are we looking
four so we’re just looking for everything inside this box which is the
brown spot and then this bigger search box from the name you can tell that what
it does is it says on the next frame you see this thing is going to be moving
right and we’re gonna track it but where should I look for this little pattern
and it’s saying only look within the contents of the search box so if it’s
very small it’s only gonna search inside the small area so it’s going to compute
fast or if I go like this it’s gonna take a long time but it will search in a
larger area so in this case you see if I play the footage this thing is moving
but not really that much so I’m just gonna make it a little bit bigger than
this okay perfect and then in terms of tracking there’s a lot of ways we can do
it we can track how this thing moves so that would be in this panel right here T
to enable and disable so that’s T you can do a location track which is what
we’re gonna do just tracking the location of this little pattern right
here you can also track things like you know location and rotation all of those
in scale perspective etc but location is good enough for us and then the only
other things we want to mess with right here is this correlation number and
basically this is saying eventually we’re gonna have this track
automatically and it needs to know how confident it needs to be that the track
is good so if it makes a decision that it’s not sure about we need to give it
instructions on whether or not it should call that correct
so the higher this number is the harder it is to get a perfect perfect result so
for example if I make this point 9 it needs to be 90% confident in the next
frame for it to keep the data if we make this zero it’s gonna keep all the data
even if there’s a lot of things wrong with it so you want to make this number
very high to get the most accurate results
so that it stops if there’s something that it’s thinks is inaccurate so I
think we are ready to track this through the video so we’re on the first frame
and we’re gonna start off by tracking manually so there are buttons right here
to do this you can just click track select marker so you can just click this
right here and it’s just gonna go one frame so if we go back and forth with
the left and right arrows you see attract it the shortcut is to hold alt
and then right arrow just like that and I’m just gonna keep hitting it and you
see it’s tracking along the shot alt and then left arrow to track
so this is a frame-by-frame mode and you can see exactly what it’s doing another
thing we can do is instead of clicking alt and right a bunch of times what we
can do is click this bun right here and it’s gonna keep going until it has a
issue with this point 9 number so let’s click this right here and you see
tracked up until frame 46 and why is that well that’s because the brush is
obstructing it so it makes sense that it stopped here so let’s actually view yes
so you see this is actually tracking on very well we can Center it by clicking
this bun right here or click L and you see now it’s locked on so if we play it
it’s kind of already stabilized in some sense so this is kind of what the
stabilized footage might look like but really all this does is it lets us view
a more centered view of our track so you see it’s tracking up until frame let me
go back frame 46 where this is obstructing now there’s nothing we can
really do without data from outside here to figure out where this is right it’s
obstructing it so what we do is we make our best guess so you see from this
frame to this frame that only moved a little so I’m just gonna hit G to grab
it and we can set a keyframe manually so I’m just gonna click here and now it
says this tracker is gonna be here for this frame and you can see when we go
back and forth if it’s correct this shouldn’t be moving that much this is
our stabilization point and you see indeed this isn’t too bad you can always
correct it so you can say it did go down a little so you can grab this and
correct for that hold shift while you move it to make it a bit more accurate
so now we have something a bit more accurate if I hit alt and then right
click again it’s gonna try to track it now it’s actually tracking this red area
right here which for this case it’s fine because it’s not moving but soon it’s
gonna be an issue so ultra-right arrow now it’s really doesn’t know where to go
so we’re gonna correct it by hand basically you just want to keep going
back and forth I guess it should be around here yeah there we go so that’s
looking more stable and looking at this path right here really does helps on
this part of the footage the camera shake isn’t too bad so all these points
should be close to each other from frame to frame and soon hopefully this brush
out of the way so we can get this unobstructed so let’s go another frame
alt right okay so it’s kind of visible here so I’m just gonna put it around
here you can also move from here like I said holding down shift to do it more
precisely another frame and now we have everything back like that so if we hit
alt right now it’s gonna track on correctly because this thing’s
unobstructed and more so we can click this button right here or control T to
have it finish the job so went up to frame 150 of course we could go further
to 272 frames right but I’m only doing the first hundred 50 frames so let’s do
a save and let’s see what we got over here
so we’re seeing that it’s locked on because we have this lock on key right
here and we’re seeing that it’s tracking on fairly well let’s see yeah even when
the brush is obstructing it you see there’s a bit of shake because we didn’t
do it perfectly but this is still pretty good okay perfect so now that we have
this thing tracked on we can actually lock it by clicking this right here so
this locks it so we’re not gonna be able to grab it and move it around and then
we can just rename it to maybe stabilizer because this is our
stabilizing point so right now I’m gonna disable this right now we don’t actually
have anything happening right we just play the video and it’s the video with
this tracker moving along for the ride right nothing special but we want this
to be our stabilization point so to do that you might have guessed you go to
the stabilization menu and enable it you then go to tracks for location and this
is saying what should I stabilize to and we’re just gonna do a single tracker
right here so we can just I’m gonna go to track and I think this should be
selected by default but you can always unlock it and make sure it’s selected go
to stabilization and then click add when this is selected and it’s gonna add our
stabilizer now I’m pretty sure we didn’t actually need to unlock it just wanted
to stress the point that it is selected okay so now we have our stabilizer and
it will only use it for position for rotation and scale we need another
tracker for more information and again if we play this nothing happens right so
you know what’s the point of this panel right here well the thing is we’re still
displaying the No normal footage so to display the new
stabilized in terms of position with this tracker footage what you do is you
go to clip display and then do show stable so the first frame is going to be
the same because our anchor frame which is saying what’s our reference for the
rest of this video this is equal to 1 so it’s saying this position right here at
frame 1 this is what it’s gonna maintain so now if I play the video you see that
it’s actually moving around and this tracker is staying locked on to wherever
it was on the first frame in this case if we change this to 10 that can move
around so it’s gonna be now stabilized on where it was on the tenth frame etc
so I’m just gonna go back to 1 and you know it’s stabilized of course the
sacrifice is that this doesn’t fill frame anymore but there’s nothing we can
do about that because the camera wasn’t there to film it in the first place
right so that’s the sacrifice we make of course you can enable auto scale right
here and it will crop this in the least amount it has to so that everything’s
filled in so it doesn’t overdo it so it’s not gonna zoom in further than it
needs to and then you see this is looking very stable probably the worst
part is gonna be when this brush is going over so let’s let’s see
yes it’s moving a little but even that’s not bad see see this is now super super
stable perfect I’m gonna turn off auto scale okay so the only other issue that
we have now I guess it’s still in Auto scale we can just undo turn this off
bring this to one okay so now we’ve undone this auto scaling so the other
issue is which it’s very subtle is again there’s this motion that’s happening
this camera shape but there’s also a tiny bit of camera rotation so if you
were to make a line here over time it’s gonna tilt one way or the other as this
camera rotates it along the footage so to get camera rotation stabilized what
we have to do is add another tracker so for example if I add a tracker here
which was our original idea we’re now gonna have two trackers and initially
they’re pretty level if I was to put one here they’re about the same height but
over time maybe this one will be higher or maybe this one will rise higher and
this horizon is gonna be changing and that gives us information about
rotations and then the distance between these two
if it grows in that must mean that we kind of zoomed into our footage or we we
came in closer to this area so the distance between these two is gonna give
us information about scale and then which one is higher than the other is
going to give us information about rotation so we’re gonna do the same
thing T to enable this menu I’m going to control click here to get a marker right
here go into track just so we see what we’re doing
scale this end a little maybe bring up the search area and we can hide that
with alt s and then we can either attract manually or just hit ctrl T and
you see that it should yep and made it to 150 frames that’s because the brush
never obstructed it yep it seems like it didn’t and you see we have a pretty good
track of course you can always go in and edit this path by hand but this is
pretty good so this track I’m going to call our rotation scale marker so we’re
going to be using this one for the position and then we’re going to be
using both of these together in conjunction to get this rotation and
scaling stabilization so what do we do we take this right we take it we go into
stabilization and now we’re going to enable rotation and scale and now we
have another window to add in more markers so we’re gonna have the selected
and click plus and we have our rotation and scale so as long as in clip display
we have shows stable now it’s going to do a stabilization of both position and
rotation and technically scale as well but that shouldn’t really matter in this
case so I’m just gonna play this so we definitely have the position and then
like I said the rotation the rotation should be fairly subtle but we’ll see if
we can find it yeah here it looks like this corner of the footage is a bit
lower than this one so there’s a tiny bit of rotation it makes sense that
there isn’t a lot you don’t see a lot to begin with but it does seem like this
coroner’s higher than this one let’s go back into our hundred fifty frame range
okay so now we’ve stabilized all that and then when we hit and we get this
menu back and then we can do auto scale and that includes when we do auto scale
I’m gonna do a max of two like it was before so that’s also
going to account for our rotation and all that like you can see we can change
this value I guess Auto scale does it to exactly the right amount but if we
disable it and then change how much it scaled in we can affect that and then
one more thing is we can change where this thing is centered keep it
stabilized but center it somewhere else like this so I’m gonna put it somewhere
in the upper right corner so you see it’s up here but it’s still stabilized
when we play it so that’s just defining the center so I’m gonna zero that back
out okay so now we have what I would consider a stable 2d track this is
two-dimensional because we just track the footage we don’t have any camera
data about how this is moving throughout the scene or anything like that nothing
crazy I will do a tutorial on 3d stabilization though I do think that’s
interesting so now we’ve stabilized for position for rotation and I guess
technically for scale so the question is how do we save our results well first
thing I’m gonna do is I’m gonna keep on this auto scale with the max of two so
that everything is taken up in the frame and it’s also stabilized so let’s let me
save so to export this what do we do well we go to compositing and then we’re
gonna enable nodes and auto render and all this and if you’ve never messed
around with this compositing mode don’t worry I’ll walk you through it so
basically we have this composite node and then something called a viewer node
which you can either add with shift a and then output and then viewer or a
faster way is if you have no Durango are enabled and if you don’t go to edit
preferences wait for that to open I don’t know why preferences always take
so long for me go to add-ons and then look up node Wrangler so make sure this
is enabled that comes with blender 2.8 and what this lets you do is select any
node and then ctrl shift click it to add this viewer as you can see so again do
that or shift a output viewer so that is control shift click so we are going to
delete this node right here with X and then what we’re going to add in with
shift a is we’re gonna add in an input and then our movie clip okay so I’m
going to ctrl shift click this to make it our viewer and also our come
and right now you see nothing but that’s because we haven’t selected a movieclip
so again right now we’re kind of setting out what is going to be exported at the
end so go to your movie clips and then I’m just gonna select stock footage
which is the same one as before and then you see in the background we have our
stock footage and if it zoomed in a bit too much you can do fit right here or
you can just click V to zoom out and then alt V to zoom in but I prefer fit
it’s a lot faster and then if we scrub through this footage it’s gonna take a
bit to update but you’re noticing that this is not stabilized so it’s literally
taking our footage and putting it in both of these right it’s not doing any
of our stabilisation so how do we get this information back well there is a
node for this so you do shift a and then I’m not sure exactly where it is we can
look for it but I dunno you can just type in stabilize in here and you have
your stabilized 2d node so I’m just gonna bring this on and what this is
gonna do is we’re gonna feed our movie clip which right now is unprocessed just
going in here and then out to both of these we’re gonna feed it through the
stabilization which is gonna do you know what we did over here and the movie clip
editor it’s going to put in the stabilization go back to compositing and
then we’re gonna feed this into our viewer and composite so let’s do that so
I’m gonna put this here ctrl shift click this perfect and you see that nothing is
showing up again but that’s because we now need to select the type of
stabilization and we’re gonna do the stabilization that we did for the same
piece of footage obviously now if we play this you’re gonna see that we do
have our stabilization and it’s also cropped in because we do have auto scale
if we disable this or bring it over to one and then disable this and then go
back to compositing you’re gonna see it should update and then yeah you can see
that it’s still moving throughout the frame and it’s not cropped in at all but
we’re just gonna go back and enable this on two like that and you see it should
update yeah there we go okay so now it’s pretty much outputting
the correct thing but how do we actually render this so again just to reiterate
we have our movie clip node set to this going into our stabilization node
so this is unprocessed being stabilized with this node with the same
stabilization as the footage and you can also do an inverse stabilization by the
way which is interesting so that’s kind of taking something stationary and
adding the motion back in which is kind of a neat idea and we might talk about
that in the future but ignore that for now and then we’re feeding it into our
viewer which is what we’re seeing if I disconnect this you see nothing and then
our composite is what is going to be exported okay so how do we actually
render this so we’re just gonna use Eevee should be fine
yeah we’ll do an Eevee render and then I’m gonna go to output again we have 30
frames per second up 250 frames and then I’m just gonna do a PNG sequence zero
compression and let’s make a folder in here we’ll call this stabilization
output so we’re gonna render our frames into this folder and if you don’t want
to do frames of course you can just export the video so you just click this
change it to the encoding to something like a mp4 MPEG 4 and you’re on your way
I’m just gonna do a sequence so it doesn’t really matter and then I’m just
gonna set our directory to be that folder stabilization output and then
output is gonna be the file name and then when we render yes yes when we
render it should do everything correctly but we will see about that so I’m gonna
go over to my first frame you can go to render render animation or just ctrl f12
okay so you see it’s going frame by frame using easy it’s very quick and
immediately you can tell that it’s cropped and it’s a lot more zoomed in
because of our auto scale and it is definitely looking like it’s stabilized
so I’m not gonna render this entire thing right now just gonna let it do
something like 20 frames and then we’ll go into that folder and make sure we
have the correct thing outputted but normally you let this go until it you
know did it’s 150 frames or 272 I think it was okay so it’s done enough so I’m
just gonna close that I’m gonna do a save and then let’s check out our folder
which is not opening there we go and it’s just littered with a bunch of
frames here so let’s open this up you know what I always find that this
photo viewer that’s on by default isn’t that fast so I’m just gonna change to
and it’s also my computer’s pretty slow right now because I’m recording but
Windows Photo Viewer is definitely what you want to be using and then we can
just right click to go photo by photo and this is looking like a dead-on
stabilization it’s barely moving and it shouldn’t be it’s probably gonna be the
worst that frame 45 46 47 where this brush is occluding our feature that we
tracked and there is a case to be made for maybe tracking this area to be
stabilized and then right when this brush comes in we can track something
else temporarily like maybe I don’t know some other piece of the cookie somewhere
else and then we can change back so there’s no need to like stabilize to a
single thing you can switch between stabilizers but generally it is better
to have a single spot just so everything’s nice and clean but there
you go that is how you stabilized in two dimensions and two dimensions I want to
reiterate because eventually I’ll do a 3d tutorial and that’s a bit more I
don’t know I guess it’s a bit more challenging a bit more involved it’s
like oh how do you stabilize footage where the camera is moving through space
but it’s actually not crazy but I’ll talk about that so again this is how you
stabilize 2d footage in blender 2.8 for rotation scale and position hopefully
you found this helpful if you have any questions ask them below
I answer most of them unless I don’t know the answer to your question which
in which case I’ll research it and find out the answer for you but thank you
guys for watching and I’ll see you guys on the next one bye bye

21 thoughts on “Blender 2.8 2D video stabilization tutorial

  • This is a very useful feature in Blender. It has been a staple in Blender for a while now. I have not tried it in 2.80 but it seems the functions are the same. Thanks for your time and excellent explanation. :O)

  • Thanks a lot for making this excellent tutorial, mate. Nicely explained and focused on just what (and all that) you need. You understand what a tutorial should be like. Great work.

  • Nice tutorial! Centering the clip correctly when you autoscale will reduce the amount of pixels you lose so keep an eye on that!

  • Don't forget to change the color mode from Filmic to Standard in View Transform to preserve the original colors. To output sound, also add the movie file to the Video Sequencer. You might have to set a resolution in the Output section to match your clip.

  • Thanks for the tutorial. I did have an issue in the last step though. My footage appears stabilised in the compositing screen, but it doesn't seem to actually render with the stabilisation. Any ideas on what might be preventing that?

  • 0. Great tutorial, thanks a lot!
    1. It would be great if you explain little bit about cropping. Autoscale works from center, and I would like to crop all sides more carefully. I can add "crop" node (as you added "Stabilize 2D"), but it disables Viewer and I can't check results. Look like this "crop" node designed for something else.
    2. If you search Google for video stabilization (even for free one) it does not mention Blender. At least on first two pages. But it will show you lot of software crap… 🙁

  • I guess Your Preferences open up so slow because it opened Add-ons right away! Its set to remember the last prefs group. Interface for instance opens up super fast. But there are quite some Add-ons to list 😃

Leave a Reply

Your email address will not be published. Required fields are marked *