Unable to create Rotobezier mask on long video.
- May 18, 2022
- 0 replies
- 356 views
I'm having a problem to create Rotobezier mask.
My script (After Effects.jsx) works almost fine, but for long video (over 10 minutes), created masks are NOT Rotobezier.
In image.jpg, for example, I created sample layer including two mask layers (Target 1, Target 2) with Rotobezier option.
Target 1, 2 are created equally without frame, however, only Target 1 looks like Rotobezier.
Does anyone have any suggestions about how to fix this?
var data = [{"target_id":1,"sequence":[
{"frame":1,"contours":[[301,200],[267,231],[260,279],[281,324],[321,351],[347,319],[351,271],[338,224]]},
{"frame":2,"contours":[[302,201],[267,234],[261,281],[283,326],[323,351],[348,319],[351,272],[339,226]]},
{"frame":3,"contours":[[305,200],[270,233],[263,281],[284,325],[323,351],[350,320],[354,273],[341,226]]},
{"frame":4,"contours":[[306,200],[271,233],[264,280],[284,323],[323,350],[350,320],[354,273],[342,226]]},
{"frame":5,"contours":[[308,200],[274,232],[268,279],[288,323],[327,350],[353,318],[358,271],[345,224]]},
]},
{"target_id":2,"sequence":[
{"frame":14015,"contours":[[275,179],[234,216],[226,275],[253,328],[299,359],[331,322],[335,263],[322,204]]},
{"frame":14016,"contours":[[275,179],[234,216],[226,275],[253,328],[299,359],[331,322],[335,263],[322,204]]},
{"frame":14017,"contours":[[276,179],[235,216],[227,274],[254,328],[298,359],[331,322],[336,264],[323,206]]},
{"frame":14018,"contours":[[276,180],[235,218],[228,276],[257,328],[301,359],[332,321],[336,263],[323,205]]},
{"frame":14019,"contours":[[277,180],[236,218],[229,275],[257,328],[301,358],[331,321],[336,263],[323,206]]},
]},
]
var layerName = "sample";
var start_frame = 9015;
var compItem = app.project.item(1);
var layer = compItem.layers.byName(layerName);
var frameDuration = compItem.frameDuration;
for (var i=0; i < data.length; i++) {
var result = data[i];
layer.Masks.addProperty("Mask");
var newMask = layer.Masks(layer.mask.numProperties);
newMask.name = "Target: " + result.target_id;
for (var j = 0; j < result.sequence.length; j++) {
var frame_data = result.sequence[j];
var frame = frame_data.frame + start_frame;
var ae_shape=[];
var intangents = [];
var outtangents = [];
for(var f=0; f< frame_data.contours.length; f++){
var x=frame_data.contours[f][0];
var y=frame_data.contours[f][1];
ae_shape.push([x,y]);
intangents.push([1,0]);
outtangents.push([-1,0]);
}
var myshape = newMask.property(1).valueAtTime(frame * frameDuration, true);
myshape.vertices=ae_shape;
myshape.inTangents = intangents;
myshape.outTangents = outtangents;
myshape.closed = true;
keyIndex1 = newMask.property(1).addKey(frame * frameDuration);
newMask.property(1).setValueAtTime(frame * frameDuration, myshape);
newMask.rotoBezier = true;
}
}[Steps to reproduce]
Step1: create long video file.
FOR /l %%i in (1,1,72) DO (ECHO file sample_movie.mp4 >> "Files.txt")
ffmpeg -f concat -safe 0 -i "Files.txt" -c copy Out.mp4Step2: load Out.mp4 to After Effects and create a sample "Adjustment Layer".
Step3: Please remove the .txt extension of "After Effects.jsx.txt"
Step4: load "After Effects.jsx"
[environmental information]
OS: Windows10
Memory: 8GB-29GB
After Effects version: 22.0.0, 22.0.1, 22.3.0.0
