Copy link to clipboard
Copied
I'm currently working on a PPro Panel that will cut the last second off of a clip and extend that clipped second duration out the next clip. I'm currently stuck on how to perform a clip cut from the script. This will be used to supply extending the visual in case the above-placed title is longer than the below clip. It'll pause the video while the title continues to finish out it's duration.
These are the notes I have so far:
app.project.activeSequence.getSelection()
this will be used to get the end seconds of a clip
app.project.activeSequence.setPlayerPosition()
this will be used to set the player position -1 second from end of selection.
I have PropertyExplorer installed and have exploring properties for a bit and haven't found the appropriate method/property to perform a cut. Help, please?
There's no cut function; you'd need to change the end point of the trackItem (clip).
var myClip = app.project.sequences[0].videoTracks[0].clips[0]; // grabs first trackItem in first track in first sequence
if (myClip){
var oldEnd = myClip.end;
if (oldEnd){
oldEnd.seconds = oldEnd.seconds + 3; // arbitrary new value
myClip.end = oldEnd;
}
}
Copy link to clipboard
Copied
There's no cut function; you'd need to change the end point of the trackItem (clip).
Copy link to clipboard
Copied
Can this be done through a different method? I'm currently working on this as a panel using HTML and ExtendScript/Javascript. Can another develop method provide this kind of automation? i.e. via the SDK
Copy link to clipboard
Copied
> Can this be done through a different method?
Yes; changing the end point of the trackItem. 🙂
> Can another develop method provide this kind of automation?
You don't need another method; you can use ExtendScript.
Copy link to clipboard
Copied
I tried updating the end point with
app.project.activeSequence.getSelection()[0].end.seconds = 20
and
app.project.activeSequence.getSelection()[0].end = {"seconds":20, "tick":existingTick};
and have had no success. I appreciate your information henceforth. Could you help me further this process?
Copy link to clipboard
Copied
Reaching out directly.
Copy link to clipboard
Copied
Hi!
did you find the proper way to cut part of tacks or clips ??
Thanks
Copy link to clipboard
Copied
The proper way remains adjusting the end point.
Copy link to clipboard
Copied
Thanks!
actualy I solved my problem)
we can use this:
app.project.rootItem.children[index].createSubClip(name, startTime, endTime,
hasHardBoundaries, takeAudio, takeVideo);
and than insert this clipped project item to sequence track
app.project.sequences[index].videoTracks[index].insertClip(projectItem, time);
Copy link to clipboard
Copied
What is the code snippet to adjust the end point?
There have been multiple responses from employees saying 'adjust the end point' without saying how to adjust the end point via script.
Wouldn't have commented about it but Google has led me back here like a dozen times.
Copy link to clipboard
Copied
var myClip = app.project.sequences[0].videoTracks[0].clips[0]; // grabs first trackItem in first track in first sequence
if (myClip){
var oldEnd = myClip.end;
if (oldEnd){
oldEnd.seconds = oldEnd.seconds + 3; // arbitrary new value
myClip.end = oldEnd;
}
}
Copy link to clipboard
Copied
You're the best, thanks!
Copy link to clipboard
Copied
Would I be able to add a clip several times, with different in/out and thus assemble the clip again with cuts exactly where I wanted, but instead of cutting I added the result of cutting in the correct order.
Copy link to clipboard
Copied
Yes; you can accomplish that, without using the (unsupported, unrecommended) QE DOM.
https://github.com/Adobe-CEP/Samples/blob/9efca02ea88ad32a8c22571f5ffe2407ae732cd8/PProPanel/jsx/PPR...
Copy link to clipboard
Copied
There's no cut function in extendscript API. QE DOM has razor(string, bool, bool) method on sequence and track objects but I failed to get it to work.
As a workaround you can use overwriteClip() with one-frame media and then delete that new media immediately, so you will have two desired cutted clips BBBBUT with one frame gap.
Another workaround is adjusting inPoint, outPoint, start and end, but it is a bit tricky: clip's inPoint and outPoint work in a strange nonobvious way, so make tests first.
Copy link to clipboard
Copied
Here you go...
// Enable Quality Engineering library
app.enableQE();
// Function to find markers in the active sequence
function getMarkers() {
var activeSequence = app.project.activeSequence;
if (!activeSequence) {
throw new Error("No active sequence found.");
}
var markers = activeSequence.markers;
var markerList = [];
var currentMarker = markers.getFirstMarker();
while (currentMarker) {
markerList.push(currentMarker);
currentMarker = markers.getNextMarker(currentMarker);
}
return markerList;
}
// Function to pad a number with zeros
function padNumber(number, digits) {
var numberString = number.toString();
while (numberString.length < digits) {
numberString = "0" + numberString;
}
return numberString;
}
// Function to add a cut at a marker
function addCutAtMarker(marker) {
var sqe = qe.project.getActiveSequence(); // Get the active QE sequence
var timecode = marker.start.seconds; // Get the marker start time in seconds
// Convert the timecode to the format "HH:MM:SS:FF"
var hours = Math.floor(timecode / 3600);
var minutes = Math.floor((timecode - (hours * 3600)) / 60);
var seconds = Math.floor(timecode - (hours * 3600) - (minutes * 60));
var frames = Math.floor((timecode - Math.floor(timecode)) * 24); // Assuming 24 fps
var timecodeString = padNumber(hours, 2) + ":" + padNumber(minutes, 2) + ":" + padNumber(seconds, 2) + ":" + padNumber(frames, 2);
// Apply the cut to all video tracks
for (var i = 0; i < sqe.numVideoTracks; i++) {
var videoTrack = sqe.getVideoTrackAt(i);
videoTrack.razor(timecodeString, true);
}
// Apply the cut to all audio tracks
for (var i = 0; i < sqe.numAudioTracks; i++) {
var audioTrack = sqe.getAudioTrackAt(i);
audioTrack.razor(timecodeString, true);
}
}
// Example Usage:
var markers = getMarkers();
for (var i = 0; i < markers.length; i++) {
addCutAtMarker(markers[i]);
}