Your First Script for DaVinci Resolve: Timelines, Media, and Fusion Nodes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
when we last left off learning the basics of Lua for Da Vinci resolve we had just finished with all the basics of Lua itself today let's get to tell the basics of resolve we're going a little bit slowly so we're not working on a full project we're just looking at some of the basic ideas that resolve has when working with different parts of the software and to get you kind of acquainted and kind of used to everything you can do what we're going to be doing is we're going to be making a timeline in a project that already exists you can also create projects and also have links to all the resources down in the description and in the top comment in the uh pinned comment that's what I'm looking for we're going to be making a timeline we're going to be first we're going to be adding a fusion comp to that timeline and then opening up that uh Fusion comp and then adding stuff to the fusion comp moving stuff around and changing the values of stuff in that Fusion comp with all that being said rambling aside let's go ahead and take a quick look look at what we're making today so if we come up here to our workspace for the scripts L Lon episode 2 run this bad boy this is our final product of what we're making today we're going to be creating that timeline we add an image we make that into a fusion clip in the timeline and then we open up fusion and then we add stuff to Fusion now I want to mention the way that we're doing stuff has a bug and I don't know if if it's just like a problem with the way that the API set up or if I'm not doing it correctly and it's just not wanting to work how I'm expecting it to so I will be asking if you know the answer to this problem let me know we'll be taking a look at the code obviously in a minute so let me know if that code works best for this situation if it doesn't please tell me a better way cuz this is obviously as you can see we have text with have a background with have two backgrounds and we have like mer and everything and we moved the media in this media in is the original image that we had put into the media pool so what we are trying to do is view the text and the text it should be viewable because it says my text baby so I don't know why it's not working there's a few reasons why it could not be I guess like this is a not an existing Fusion comp that's like functioning we're also doing another version of this where we're just not adding any images and turning into a fusion clip we're just adding a fusion uh a comp into the into the timeline so let's take a look at both let's go and take a look at that right now all right let's go to brand new file here and let's go ahead and save this to our scripts folder into utility this can go in I guess comp it can go in utility it can go in edit uh it can go in a bunch of different places but utility will put it up near the top utility always goes above all the other sections no matter what page of Da Vinci you're in so always you know I always like to choose utility for these quick projects so we'll just say um tutorial file DOA and let's go ahead and start writing so so first things first when working with anything in Da Vinci resolve besides the comp and I'll get to compositions and fusion and everything later uh because they're weird mostly because this scripting language and script environment was originally made just for Fusion back when it before was like bought but like this was made just for Fusion back before it was bought by Blackmagic so this was just with Fusion in mind so it is not really made for resolve so what you have to do first because of all this is you have to connect to resolve to get the data that resolves stores so we have to make a variable and we're just going to call it resolve going set this equal to resolve with parenthesis and that's how you can get resolve and now we have to get the project manager which is the basically if you open up resolve again this guy down here this little house is called the project manager so you can get all the different project libraries and then all the different project databases and all the projects themselves the folders and everything so you're able to do a lot of different things with that and we might get into that stuff in another video but that is when you're wanting to run a script as like a standalone environment script one that doesn't necessarily want to be run inside of Da Vinci because the only way to be run it directly from D Vinci is to actually get it from workspace scripts you can't run it from the project manager there isn't the workspace option on here so you'd have to have another software like if you know Willam justices super super bins and he also has uh switch switch notify both of these to my knowledge use the same scripting API to connect into Da Vinci resolve and run different scripts during different things so that's how you can do it with that in mind so if you wanted to do a project management script you can do like a python script that has the pi the python UI um that's built into it the for and you can use that to create a like database Creator if he really wanted to for some reason cuz as if it's not easy enough to do maybe you can do one for like bulk creating of folders or projects or bulk backing up of things if that's an option I don't really know if it is I'll have to take a look at it I don't I don't know anybody who's really made stuff like this but yeah you can do lots of different things with this stuff all you have to do is look for what you can do by looking in the right places and I can show you that stuff a little bit today and a little bit in future videos so we have to connect that project U manager and we're going to get uh project managers uh the project manager uh variable is going to be using the camel uh caps which is first capital is lowercase second capital is uppercase if you're using multiple words in a variable name you can also then do underscores if you want to do that but it's a lot more popular nowadays to use the camel caps and we'll just do resolve and then get project manager and we have to call that same resolve because it has to know this instance of resolve that's running we have to get this instance of resolve as project manager then we have to from that get the project recur on the end so I have to get the project call it from the project man manager and then look for the current project bam there we go a lot of these things with the DCI resolve API and scripting stuff is very very self-explanatory not a lot of this stuff is hard to understand like next we're going to get the media pool guess how we're going to get that we just have to type in project and guess what we're going to type in get media pool like this stuff's really really simple it's not that hard to set all this stuff up so now we are getting this the information that's inside the media pool so we can add and look at the things that are currently sitting in our little system our little bins and our pictures or Audi or videos all that kind of stuff so with that said all we really just did there is we went resol we got the project manager we got the current project and then we got the media pool and in theory this is the exact same thing as what we just did with all these in theory I don't know if it's actually going to work cu the way that these work is weird let me know if there's a way to actually make this work because that'd be really fun so if you really wanted to make it on on line I guess you theoretically could but people like to do like this so that if you wanted to any point in the script call for the project manager or call for the project settings themselves you can just call for project in set that setting at any point in the project so it's super super easy to set up that script that way so at any point down the road you don't have to like worry about it now we're in the media pool and that's where timelines are made and we're not going to look for a timeline so kind of think in your head what are the possibilities of what this next line of code could be so we're going to write local going to say timeline May maybe if I can spell correctly and we're going to say media pool okay create okay empty timeline not only can we just create a timeline called timeline one or Untitled or whatever we can give it a little name like I don't know we can just call this title graphic timeline and there we go now we just quickly organized that for the user sweet and when we look at making uis we might look at this at the end of this video we can turn this into a variable that the user can actually type into a a text line and we can actually let the user type in the name of their own timeline so that they don't have to worry about having some random default name being used over and over again creating duplicates that it can be hard to follow all that kind of jazz so what we're going to do first is we're going to insert a fusion comp just straight into the timeline not adding stuff into the media pool so we're going to do timeline Fusion comp going to use the timeline uh parameter and going to insert Fusion composition into timeline give it some parentheses and there we go in this instance we're going to get all of the comps that could exist on that timeline clip so even though it is a fusion comp it is still a timeline clip that could have multiple Fusion comps because of effects so we have to get all the comps by looking at the Timeline Fusion comp and then getting Fusion comp name list and call that function and we're just going to call for the very first item in that list so we're just going to do timeline Fusion comp once again and we're going to do load Fusion comp by name and we're going to type in comps and then do zero and this should give us the first comp in that List's name which theoretically should be this comp name this is why I say I may be doing this wrong this might need to be one and I'll go and set it to be one see if that works but there may also still be a way that I'm doing this incorrectly so do please let me know if I'm doing this wrong because there are plenty of ways I could be doing this wrong the the scripting information for this stuff has very very little actual documentation that makes a lot of sense for new people so trying to figure out how to make certain things work sometimes doesn't always go in your faith okay so now that we have the fusion comp active your head might think okay cool now we're actually in the fusion page the fusion page is visibly in our site no actually not because you can have an active Fusion comp but not actually be in Fusion why because when you're in a timeline and you have an effect if you turn on if you go into Fusion at any point you've activated that comp and now that comp is active so what we have to do now is bring ourselves into Fusion which isn't too hard we have to call for resolve which is also a great reason why we have those other variables up there and we literally just call open page and then lowercase the name of the page like we can make this say edit deliver cut uh media pool or media whatever okay now this is where things going to get a little bit weird now we are actually getting the information from the fusion page but first we have to get the fusion comp that is actually active theoretically it should be this comp but to be safe we have to do a few things to get the actual comp so we have to just like how we got resolve we have to get Fusion in the exact same way how we got resolved because this is an instance of fusion that is being launched from resolve so it still counts as a separate app I guess technically speaking so if we uh get Fusion we then also have to set Fe to Fusion this is just a very common way of doing it you don't necessarily have to set few to Fusion so it's up to you you can use this or not it's it's good practice to have it set like this now we have to get the composition which we can just look for the composition like this look for it in few and then use dot current comp just that easy so Fusion has its own environment to where like you can use the fusion environment and get certain things like this without needing to use those parentheses every single time like all these other ones up here here and you can see it also uses weirdly different syntax to where this is using a period and these are all using semicolons which is why when I say if you want to make all this stuff in Python it's pretty much everything is the exact same but whenever you see a period if that line of code isn't working change that period to a parenthese and then vice versa just swap your periods in parentheses if that Line's not working and most like it'll work because most likely it's the different language that's what I've have learned from doing this a couple of times all right so now we have the current comp we're just need to set comp equal to composition so the exact same thing is happening here we don't have to do this but this is just shanding this line of code so now we have the active comp we then make have to set the active comp to comp and what this is really doing is in the script it is setting the comp to comp for whatever reason whenever you're going just straight into Fusion if you launch the script when Fusion is already open and already has an active comp then it won't require you to do any of this set up for some reason it requires this if you go into it afterwards without Fusion being open first we're going to teach you some more stuff from the Blackmagic design environment in the last video we did bmd do WR string this turned a table into a readable string we could print and we can use this in plenty of different other places too now I want to teach you some other things you can do with bmd you can do bmd do weight and this is a timer of sorts and this is set in second so we can set this to wait for 2 seconds and then finish the script so what we're going to do is I'm actually going to dump all the bmd stuff so you can see all the stuff we can use so we're going to dump bmd and before we even continue I just want to show you what is happening so what we should be seeing right now is we are getting all the information about the project so we shouldn't even see anything happening there it should create a new timeline add a fusion comp to the timeline and before we can even like process what's just happened we should load the fusion comp go into Fusion set the comp to active and then dump the bmd information into the console if we run the script now go into scripts find what we named it we called it just tutorial file and Bam before we even noticed what just happened we are in the we're in the fusion and we have bmd dumped so let me explain and show you what's going on so if we look at the first section of each these lines this is what we can type into the code so before each of these we can do bmd Dot and then we can type in any of these so just like last time if we do bmd dot like right string we can turn any table into a string instantly with just doing bmd do dot whatever you typed in we can do that with any of these so if you look at what they say they're pretty self-explain it so just like everything else we've looked at so far a lot of this stuff just makes sense of what it does if you read it so we can see we can see this one says copy file and I wonder what that one's going to do we can see this one says get the extension so this says getting the file extension we can get the file path the file name we can trim the extension off of it we can move a clip we can remove directory which is removing a folder we can uh check to see if a file exists or if a directory exists we can get the current directory or set the current direct we can change something to a user data we can do the weight we can uh set a uid we can set the clipboard get what the clipboard is you can do a lot of different with this so I hide L suggest that what I just typed into the code over here if you do dump and then bmd you're going to get a bunch of different things you can do with the da Vinci resolve Blackmagic design environments and all that stuff and once I was shown this by people over at the wi L Forum I was completely taken back there is so much you can do it's fairly easy to find but it's not written down like anywhere Okay so now we're in the fusion comp and we want to start changing a few things you know what we want to do first is we want to lock the comp this is going to make sure that if you're going to have anything popping up on the screen that that doesn't happen so if you're going to be adding in a loader node which would normally pop up a UI asking the user what do they want to load in this loader uh that wouldn't happen if we lock the cop so all we have to do use our big strong brains and think hm what would lock the comp maybe comp lock dude this stuff isn't rocket science I promise you this stuff's way easier than you maybe think it it is initially you just have to use it a couple of times and you can start getting used to it now to be fair we're doing some really easy stuff when we start getting into combining the stuff we talked about in the last video with the stuff we're talking about in this video that's when things are going to start to get a lot more complicated a lot more confusing for a bunch of newbies cuz we're going to be talking about recursive Loops going through tables going through lists and a bunch of other really complicated things with user data and getting those in tables and reading those as strings and looking at different things in different ways and organizing your data and organizing your files and scripts there's a lot to go over so let's go slowly what we're going to do as we as we lock up the comp is we right after we just want to set it to unlock why because we like chaos no the real the real the real reason is we don't have to worry about that later now so we want to add in some nodes first and foremost I want to add in a background node so we're going to add a variable call it background and this is basically like background one we are creating a variable in our code and this variable holds everything that that background node is and could be so you want to do comp add tool cuz all nodes are called tools don't forget that and we just want to call for the basic ID version of the name of the node so background without the capitalization there and with know one two or whatever we're going to then set its coordinates which we're going to set it to one and three uh but if we were to remove this we're and just quickly add this in so we can just you can see what's happening first off I just want to show you what's actually going on so if we make a our project over here and completely delete everything in it let's go and run our script again we get a node appearing and it appears kind of up here and to the left so we want it to be in a configuration similar to this so we want our background node to be in the bottom section down here and we want our merge node to be in line with media 1 so we have to set coordinates to one and this is setting us uh so this is our left and right so this setting us over to the right one because positives to the right negative to the left and then we also want to go away positive3 down so positives down negatives up and then this is going to set us a little bit closer to the media out and then down three like of the gr of the grid movements down now if we were to let's go ah and add a few other nodes real quick before we actually look at this we're going to add another node and in VSS code I just did a control D to duplicate a line I'm going to add a new node for a merge node it's going to still be one and I'm going to make it in line with uh one instead of three and change this to be merge and then we're just going to add a couple of other nodes actually we're going to add all the nodes we want to use and just so we can get them all in here we're going to add another background node and this one's going to be at -3 o not 03g -3 and positive 1 and this one's going to be a text plus node at -1 and -2 this last one is a merge at -1 and 1 cool so now if we were to look at this and run it from scratch and see we get an interesting looking formation over here so now we have all of our nodes in place let's quickly look at another way to actually add a node I did want to mention this first but let me show you this right now instead of adding a node with ADD tool since we are using the environment of comp right here where settings set active comp right here we can now use a different way to actually add a node just immediately into the comp there's a reason why we're doing it this way however if we were to add let's say a background three we can literally just type in background capitalized with parenthesis and this adds a background but it adds it in that default location so not where we just put it but actually in line with the mediate out one so you can't actually select the coordinates and I've tried you cannot change anything inside the parentheses to set as coordinates so this is great if you want to add one node but you can't add multiple nodes in a formation like what we're doing right now so really good but not what we want we can also though add another way that a user can add a node we can just do node choose tool and this lets the the user use that popup menu that little search popup window using shift space and you're able to let the user search for whatever tool they want those are two cool things that I wanted to show off but today let's finish up by looking at connecting all these inputs together and all the outputs and everything if you have looked at my macro Series in the past we have looked at some of the stuff before so this is kind of just a recap for you kind of merging the two IDs together so you can see where the connection lies so now we can type in media out one because we know for fact it's going to be called media out one because this is a brand new Fusion comp we want to connect the input of that node to and the input it's called input of the media one to a merge one we know that's going to be its name because it was just created we then want to get merge one and we want to uh connect the background input to background one and so on for each of these other inputs so we want to do foreground and we're going to connect that to merge two and so on and so forth and I'll catch up with you guys here in a second all right now we got that settled up let's go and make this again go and reactivate our script here and we can see everything is connecting up just as it's supposed to you can see this background is going into the background of the merge one so this is setting the scaling of the entire comp we can see there's nothing in the text and this is black we want to set this to be uh Alp being down to zero along with this one and we also want to type something into this text so let's go ahead and figure out how we can do that too and there's at least least two ways to do this now let's come on down here and really simply we can just type in text one dot style text because style text is the ID of that control that input and we're going to do it at frame zero not that it really matters too much if there's no key frames and we're going to set that value to be uh text is epic woohoo cool and uh that's going to do exactly what we want it to it's going to take text one it's going to take the control style text at frame zero and just change it to say text is epic woohoo the other way to do it is by doing a set input so what we can do is we can take the merge set input we can do size that's the control I want to change and just for example we want to change it to like 1.25 and just to show you that you can do this you can also set it to change it on frame 10 so like this is the value that you're changing to two and this is the frame that that change will happen on if there's a key frame there if there's not nothing will happen we can also come into here and set our backgrounds to both uh set to zero so we're going to do top left Alpha and we're going to just set it to zero at frame zero and we're g to do that again with background two cool now if we were to run this we're going to see that we get text is epic woohoo we get this background has Alpha at being zero and this background has the same and we can also see that merge one has size being set to 1.25 so those are the ways you can set values really quickly with your NES and since you just seted those nodes you know what they're called so it's really easy to set the value all right before we move on to the last little couple things I want to show you guys another way to add the fusion comp to the timeline along with adding stuff to the media pool and adding that into the timeline so going back up here to the Top If we were to take a look at insert Fusion composition into timeline let's go ahead and comment that out and quickly comment stuff out like I just did if you type in control hold it down and press Q that'll comment out the entire line you have selected or multiple if you have multiple selected so coming down here we're going to do a couple of different things so first we need to import the information into the media pool so we need to do local and we're going to do media pool item let's move my cursor here and we're going to set that equal to Media pool import media and then for this we need the location of our file and this could also be something that we get from the user so what we're going to do is I'm going to copy something from off screen you're going to most likely see that your file path comes in with a bunch of Errors that's because uh when it comes to Strings it does not like these backslashes because for this instance they're designed to be like new lines so what we can do is just do another backslash and that will let theod think of it as just one backslash that just tells the code okay this is meant to be backslash it's not meant to be calling anything else like a new line or a style function so now this is going to be bringing in an icon my icon from my files and just putting that into the media pool and doing nothing with it it's just going to sit there let's go ahead and with this item we can just go ahead and add this clip to our timeline so we can go ahead and get our local clip we can get it from the media pool and I pinned this item to the timeline and we can just get the item which is going to be media pool item just like this and it has to be the data version of the item not just the item name so it can't just be like that clip's name you have to have the data information of the clip and you can do this with very with various different ways you can get all the different clips from a media pool folder so it's not too hard but make sure you don't just have the name you have everything about it now that you have it in the timeline what we have to do is turn it into a fusion clip so what we have to do is do local timeline Fusion comp just like how I had before we're going to set it to timeline create Fusion clip and we're going to set it to be clip so in here is just all the clips and you can do comma and multiple different clips and these are all the different clips you're turning into a fusion clip cuz if you don't know you can select multiple clips and turn it into a single Fusion clip to do like uh like multi cam collages and stuff like that so now just like this the same line of code is now being used down here so now we don't have to change any of these other lines of code to get our Fusion compact activated so now theoretically if we were to run this it should do the exact same thing we were just looking at before but really quick I want to show you guys how to come down here and actually activate the stuff in the flow so this is all the stuff where like the nodes are stored where all the like nodes are being free formed and being moved all about you can actually access that information as well so what we have to do is get flow just like a regular variable so we can do local flow and equals composition do current frame just like how we did before with getting the current comp we have to do the exact same idea here do flow View and this is getting all the data that's inside the flow so that means the node positions the node colors probably even like your bookmark locations and all that kind of stuff so with the flow information we can do something special with it let's go ahe and save this for now let's take a look at our project as of now let's go ah and remove let's go and remove this stuff and run the script once again uh we can see I did type something in wrong I had to quickly come back and change something I accidentally added an extra capitalization on that L there quickly double check everything else I think we look good okay let's try that one more time this can happen a lot don't worry errors happen all the time don't get to but hurt about them just see them as something that you did wrong and you can do right in the next time okay run this again we can see got turned to the fusion comp now we can see it is positioning everything in here correctly but we can see our media in1 is just kind of sitting here it's just kind of in the way well good for us we can actually move that since we're not using that uh node in our Fusion comp at all we can just kind of scoot it out of the way by doing flow which is what we're getting over our node information from set the position of what node media and one in what position is it going to be we want it to be left and right five up and down four we're going remember positive is to the right positive is down and now that is going to set its new position and now there's one final thing I want to show you and then we can call it quits unlucky all the War code stuff finally we could also set the active tool if we call comp set active tool which active tool is the tool that's in red which actually has more power than you'd really think it does in Fusion what we can do is because we don't necessarily have the data of all the nodes we could do like get tool list for all the different nodes and then like narrow it down to like what one node based off of some met metadata but what we're actually going to do is we're just going to kind of throw it out to the wind we will be getting the list of all the different nodes but what we're going to do is we're going to so this is how we get all the nodes we're going to do comp. get tool list and in the parentheses false is telling us that uh we're not looking at the selected nodes we're looking at all the nodes and we're looking for the type of node being merge and we want to do that for the first item in that list so we're going to set the active tool to whatever is the first item in that list of tools so it should be merge one theoretically but I didn't really mention this in the last video but in Lua tables aren't stored uh in order there is no order to tables in Lua because why wouldn't there be obviously that sounds like a silly thing to want there are some workarounds to it but generally speaking there's no easy way to get ordered tables in in in Lua so we can hope this is going to be Media or going to be marriage one this could be Marg 2 it's kind of a lottery but if we were to run the script now we can see it did all of our stuff there brought us into here and it moved everything to its correct places pretty cool and if we were to try to preview the image we can try to preview it try to pre preview our text and we can see we can't preview it this's goes back to the problem I was talking about before if we have a fusion clip it doesn't want to work to where we can actually see what we have inside of here we can see we have our text we can see we have our everything going on just how we had it before we have everything set up just how we wanted it to be set up but we can't see it and I don't know why if we were to go back into here real quick let's change everything back to be just the fusion clip no image in here also change this let's run this again now okay now we can see it's not giving us an error before it didn't give us an error so I don't know why it's upset now that's really weird I don't know when it comes to going between fusion and other parts of Da Vinci it can get a little bit wonky so practice the heck out of things before you finalize stuff research the heck out of things if you looked in one place that's not enough look in at least two if not three if not four because the answer could be anywhere and it's just a matter of trying to find the right place to host it I originally had planned to also be teaching about some UI stuff but I think I'll be getting into some of the basics of that in the next video so in a couple of weeks I'll be talking about UI with diin resolve scripting uh I want you to put it in here but again no time uh it should be some basic introduction stuff but just like how I said before I want to be doing a series to where I go through making a whole project so please in the comments of this video and the Discord wherever you really feel like putting it let me know some ideas that you have for a full flight script that you want to see made I'll brainstorm some ideas and I'll come with I'll come with some uh to next week's stream uh please do come with some as well if you have some but of course don't worry about it and this week's stream we'll actually be going over uh the previous L tutorial uh homework of making a story using the stuff we learned so using functions and variables and all that kind of stuff I'm not going to give you guys homework today because there's a lot of involved stuff and I didn't necessarily teach you anything particularly in like particularly specific all right if you are still new to Lua I do suggest watching this video right here I think you'll learn a lot out of it we go over the basics of Lua for beginner for coding and it really goes over everything you really need for coding for Da Vinci resolve scripts I think it goes over some really great information and it helps combine with this stuff that we learned today and for the next video it's going to really compound into some really really complicated things so if you haven't learned Lu yet please watch that video and learn a bunch cuz we have a lot to go over all right I'll see you guys in the next video Happy scripting and I'll see you with the macros
Info
Channel: Asher Roland
Views: 283
Rating: undefined out of 5
Keywords: Asher, Asher Roland, Roland, Davinci Resolve, Fusion, Presets, Templates, Davinci Resolve Presets, Scripts, Lua, Davinci Resolve Plugin, Scripting, Video Editing, Fusion Nodes, Media Pool, Timeline Creation, DaVinci Resolve Basics, Video Tutorial, Editing Tips, DaVinci Resolve Guide, Fusion Tab, Post Production, Scripted Workflow, Video Clips, Node Editing, Beginner Tutorial, Resolve Scripting
Id: lcqX90tRye4
Channel Id: undefined
Length: 40min 37sec (2437 seconds)
Published: Fri Jul 05 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.