After making a long script on the fly and smoothing/simplifying it, I am often left with a ton of motions that are around 67 ms apart (often with another motion right next to it at 133 ms that is fixed by moving the point over 1 frame). Is there any way to automatically adjust those to both be 100 ms? Or am I stuck going through manually and adjusting each point as I find them. This part of the finish is very tedious and takes about as long as scripting the entire video in the first place.
Quality takes time, I don’t even use “on the fly” scripting as I have found those who do tend to be a bit off on timing because they are reacting to what’s being shown so there will be a delay.
Since funscripts are JSON, it would be very easy to write a few lines of javascript to do what you want.
Something like this:
const newActions = [funscript.actions[0]];
for(let i = 1; i < funscript.actions.length; i++) {
if(funscript.actions[i].at - funscript.actions[i - 1].at < 100) {
newActions.push({pos: funscript.actions[i].pos, at: funscript.actions[i - 1].at + 100});
} else newActions.push(funscript.actions[i]);
}
const modifiedFunscript = {...funscript, actions: newActions};
That would break if there were many actions in a row less than 100ms apart, but would otherwise work well.
That sounds great and may be exactly what I need! But how do I go about applying that to the funscript? I don’t know a lot about JSON/Javascript. Thanks for your help!
Hmm…yeah if you don’t have a javascript development environment set up it might be a little tricky.
This got me thinking, so I added a new feature to funscript.io - now you can paste in some javascript and it’ll modify the actions array with that function!
I made some attempt to keep this in a box, but there’s some possibility that it does bad things (since this basically allows you to execute arbitrary javascript), so be careful with the feature, but it lets you do what you’re after. Just paste the following code into the box (click “Custom” on the Modify page) and it will do what you want
actions => {
const newActions = [actions[0]];
for(let i = 1; i < actions.length; i++) {
if(actions[i].at - actions[i - 1].at < 100) {
newActions.push({
pos: actions[i].pos,
at: actions[i - 1].at + 100
});
} else {
newActions.push(actions[i]);
}
}
return newActions;
}
Wow! If that works I will be so happy as it will save me hours of editing over time. I’m about finished with my current one manually fixing the points. I will try it on my next one and see how it looks! Thanks so much!
No worries - let me know if it does actually work haha
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.