Welcome to WSL!

Make yourself at home, but before posting, please may I ask you to read the following topics.


Posting 101
Server space, screenshots, and you

Thank you!

PS. please pretty please:


Image

Copying keyframes from many separate comps into one single one

Moderator: SecondMan

User avatar
TheBloke
Posts: 26
Joined: Wed Jun 17, 2020 6:02 am

Copying keyframes from many separate comps into one single one

#1

Post by TheBloke » Tue Jun 30, 2020 3:53 pm

Hi all

I have a complex macro which I have deployed in 18 Fusion comps inside Resolve 16.2.3. These macros now have many keyframes set on 6 different parameters on the macro.

I have two issues:

1. I now realise I need to change several aspects of the macro

2. I've realised it was stupid to use 18 separate Fusion Clips, and therefore require 18 separate Fusion comps. I would love to merge all my footage clips into a single Fusion clip, and therefore have a single Fusion comp that covers the entire length.

I'm planning to try and deal with both issues at once. I'll make a new macro with all the necessary changes and deploy it into a new comp. Then I will try and copy all the keyframes for the necessary parameters from the 18 existing comps, into that new one. Later in Resolve I will then copy the clips from the 18 separate Fusion Clips into one single Fusion Clip, which will have the new comp on it.

My current thought is that I would first export the 18 comps that need to be merged, and open them in a text editor.

Then I will go through them in order, copying out the relevant keyframe sections, like the following:

Code: Select all

	KeyFrames = {
				[0] = { 0.23, RH = { 25.6666666666667, 0.23 }, Flags = { Linear = true } },
				[77] = { 0.23, LH = { 51.3333333333333, 0.23 }, RH = { 77.3333333333333, 0.153333333333333 }, Flags = { Linear = true } },
				[78] = { 0, LH = { 77.6666666666667, 0.0766666666666667 }, RH = { 96, 0 }, Flags = { Linear = true } },
				[132] = { 0, LH = { 114, 0 }, RH = { 161.663699507713, 0 }, Flags = { Linear = true } },
				[221] = { 0, LH = { 191.336300492287, 0 }, RH = { 466.333333333333, 0 } },
				[957] = { 0, LH = { 711.666666666667, 0 }, RH = { 967, 0.0766666666666667 }, Flags = { Linear = true } },
				[987] = { 0.23, LH = { 977, 0.153333333333333 }, Flags = { Linear = true } }
			}
I would then paste these into the appropriate section of the new main comp, having first incremented the frame numbers by the appropriate offset. I'll need to increment frames because all my current comps start at frame 0, which won't be true if I have a single comp that spans the entire duration.

I will try and put together some quick Lua that can do the incrementing for me automatically - ie some script that takes in a Keyframes table like defined above and an increment amount, then outputs to stdout the same table but with the indexes incremented. Then I can manually paste that into the new comp.

Before I embark on this I'd be most grateful if anyone has thoughts or advice. It seems like it should work in theory? But maybe there's a better and cleverer way I'm not aware of? And are there any pitfalls or possible stumbling blocks I should be aware of? It's still possible I might not try the second step and will just live with 18 separate comps. But I'd like to give it a go if it seems like it should be possible to do in no more than a couple of hours of work.

Thanks very much in advance for any advice!

User avatar
TheBloke
Posts: 26
Joined: Wed Jun 17, 2020 6:02 am

Re: Copying keyframes from many separate comps into one single one

#2

Post by TheBloke » Wed Jul 01, 2020 2:16 pm

Done :)

I was worried it might take a while, but in the end it only took 10 hours... :D

Nah, a lot of that was making final changes to the nodes before I made the new macro, for what I hope will be the last time. And then it took me quite a while to do the Resolve Edit page work, making a single Fusion clip out of my 18 separate ones. Partly due to Resolve annoyances (like there being no way to Decompose In Place with a Fusion Clip), and partly because several of the clips couldn't just be copied over because they didn't match the length in the main scene timeline, so I had to do some trimming with careful cross-referencing of frame numbers.

The actual Fusion keyframe copying part took a couple of hours. I wrote a very basic, very crap Lua script that took an argument of a keyframe offset, and read in a KeyFrames = { ... } table from stdin. It then added that offset to each key in the table and used serpent to dump the table to stdout, still as a Lua-readable table.

Then it was a case of opening each saved comp, copying each KeyFrames section and pasting into my script, then copying the script's output into my master comp in the appropriate place. Six keyframe sections per comp, 18 comps, 216 copy & paste operations. Then I could just copy that comp definition into the Fusion composition.

And it seems to work. All the camera moves look to be correct. Won't know for certain until I render out the new scene, which I'll do overnight as it takes a while.

No surprise of course, it's just a basic Lua table after all. But I've had so many things go wrong, and things that seemed simple turning it massive timesinks, that it's always nice when something works as expected, more or less first time :)

If I ever have to do this again, I'd like to make a better script that could read KeyFrames sections out of one comp and write them into another. I didn't want to go down that rabbit hole right now, as I really need this project done. And of course if/when I do a project like this again, I'll know to set it up better to start with :)

If I or anyone ever did make a script for this, it'd be really nice to have an in-Resolve/Fusion script that allows copying Keyframes from one tool and writing them to any other, and also be able to copy all the keyframes for specified tools out of one comp, and write them to the current or any other comp, with to-from mapping, in case the tool/parameter names don't match.

Anyway, it's really nice that Fusion comps are simultaneously human-readable and machine-parseable. Certainly makes life a lot easier. If only it was as easy for Resolve project data..

User avatar
ShadowMaker SdR
Fusionista
Posts: 896
Joined: Sun Sep 21, 2014 6:17 am
Answers: 8
Been thanked: 36 times

Re: Copying keyframes from many separate comps into one single one

#3

Post by ShadowMaker SdR » Wed Jul 01, 2020 2:22 pm

This may be a stupid question, but why was this less work than just offsetting the keyframes from within Fusion's splineview? It has options for off-setting/scaling both time and values. I don't know your exact setup of course, but to me your approach appears to be rather complex.

User avatar
TheBloke
Posts: 26
Joined: Wed Jun 17, 2020 6:02 am

Re: Copying keyframes from many separate comps into one single one

#4

Post by TheBloke » Wed Jul 01, 2020 4:03 pm

ShadowMaker SdR wrote:
Wed Jul 01, 2020 2:22 pm
This may be a stupid question, but why was this less work than just offsetting the keyframes from within Fusion's splineview? It has options for off-setting/scaling both time and values. I don't know your exact setup of course, but to me your approach appears to be rather complex.
If that would have worked, then it does indeed sound like a lot less work than what I did! But I didn't know how to get that to work.

I did look briefly at the Spline editor before I made my post yesterday, and I saw "Paste with Offset". However when I tried that it only seemed to let me offset the Y value (ie the value of the keyframe, not the time). And when I tried copying multiple keyframes across multiple parameters, the option to "Copy Points" was greyed out, with only "Copy Value" remaining. And that didn't actually seem to put anything on my clipboard history, or give me anything to paste.

Copying parameter by parameter wouldn't have been too big a deal, but the main issue was it didn't seem like I could offset the time, only the value?

Another thing I wasn't sure about was whether the spline editor could handle pasting keyframes if the source of those keyframes was technically a different tool. As well as merging 18 separate Fusion comps into one, I was also changing the macro on which those keyframes were stored. The names of the parameters were the same, but the actual macro definition itself would be different. I wasn't sure if that would affect things.

Changing the macro as well was complicating things I thought: I couldn't simply copy the tool from the comps and then Paste Settings, because the macro definition had changed in several areas. I needed to be able to copy the keyframes only, on 6 specific parameters.

So the short answer is: I did it the way I described because that's the only method I could figure out. That does not at all mean it's the best method!

For future reference it'd be great to know if it could have been done with the Spline editor alone?