Copy link to clipboard
Copied
Hey swarm!
I have one greenscreen video file cut into seperate layers using the scene detection function - as this sequence is final cut that has been cut from 5 different camera views before I now have the file split. My goal is to name the layers corresponding to the 5 different cam views like CLOSEUP, TOTAL, WIDE, etc.
after keying all those cuts are transparent and I want to add a backdrop that fits SCALE and POSITION paramerters of the camera views. now I sure could set holdkeyframes at every over 100!!) cut, but my goal is to give the POS and SCALE parameters an expression to detect the layer name or layer color to set the parameters at the next cut. I asked chatgpt to write such a script, but this just set the parameters for the last cut before the backdrop layer over the whole timeline. setting the scene detection to create pre-comps for each cut didnt work either - find the expression followed below:
// Define scale values for each camera angle
var scaleValues = {
"wide": [100, 100], // Scale for Camera 1
"english": [120, 120], // Scale for Camera 2
"halfclose": [146, 146], // Scale for Camera 3
"close": [175, 175], // Scale for Camera 4
"superclose": [200, 200] // Scale for Camera 5
};
// Get the current composition
var comp = thisComp;
// Initialize the final scale value (default to [100, 100])
var finalScale = [100, 100];
// Loop through all layers in the composition to check their names
for (var i = 1; i <= comp.numLayers; i++) {
var layer = comp.layer(i);
// Skip the background color layer itself
if (layer == thisLayer) continue;
// If the layer's name matches one of the camera names, update the scale value
if (scaleValues[layer.name]) {
finalScale = scaleValues[layer.name];
}
}
// Return the final scale value to be applied to the background color layer
finalScale;
any clue how I could get this to work and save alot of time, as this would be just one out of several videos I need to use this on! thanks in advance for your help!
Copy link to clipboard
Copied
"layer" is a reserved keyword, so using it as a variable name anywhere is an absolute no-go. It will always reference back to the default intrinsic layer relationship. Same for stuff like "value" etc.. You may want to actually read the online help on the basics rather than blindly relying on CrapGPT. The rest just fails because you are not actually tracking and counting your string occurrences in an extra loop and using methods like instanceOf() and what have you. Naturally it will always go through all of them and report the last one it finds since it simply doesn't know that there were previous occurrences. This is much more complex since you likely will also need to keep track of the time info to avoid confusion. Just relying on names would be unsafe.
Mylenium
Copy link to clipboard
Copied
The only thing I can see that doesn't seem to work as expected, is this line:
if (layer == thisLayer) continue;
which should probably be:
if (layer.index == thisLayer.index) continue;
Are you getting an error message, or what exactly is the issue?
Copy link to clipboard
Copied
I would approach this project like a major studio would. Each camera angle would be a separate effects shot. I would do the compositing, render the composite (the comps), and then do the final edit in an NLE.
After Effects is not a video editing app; it was never intended to edit movies. You will get a better result in less time unless your final edit tells the story best using every frame of the edit-detected footage. Sometimes, shifting an edit point by only a couple of frames can turn a sequence or scene from a love story to an argument.
Dan and Mylenium have given you hints to the problem with your expression. I'm trying to give you some suggestions that can save you some time and have the potential to improve the story you are trying to tell.
Copy link to clipboard
Copied
You want an Expression but you prompted for a script. Why? This Expression is going to be unnecessarily slow; having to check every layer in the comp.
Try this approach for scale -
thisLayer.name.includes("Wide") ? [100,100]
: thisLayer.name.includes("english") ? [120,120]
: thisLayer.name.includes("halfclose") ? [146,146]
: thisLayer.name.includes("close") ? [175,175]
: thisLayer.name.includes("superclose") ? [200,200]
: [0,0]
Take note that the includes method is case sensitive and does not work with Exact Match. Hence, Wider, Widen, makeWide will all provide a True result. HTH