Copy link to clipboard
Copied
I need to trim clip from start and end for 1 second:
var files = ["21.mp4","22.mp4","23.mp4"];
var media = app.project.rootItem.createBin("Media");
app.project.importFiles(files,true,media);
function getMediaByName(name,folder) {
for(var i=0; i<folder.children.numItems; i++)
if(folder.children[i].name==name)
return folder.children[i];
}
start = 0;
seq = app.project.createNewSequence('test','/Temp/test');
for(var i=0;i<files.length;i++) { // I need to insert videos in same sequence as in array
cMedia = getMediaByName(files[i].split("/").pop(),media);
seq.videoTracks[0].insertClip(cMedia,start);
clip = seq.videoTracks[0].clips[(seq.videoTracks[0].clips.numItems - 1)]; //last inserted clip
// trimming 1 secod from start and end
inPoint = new Time();
inPoint.seconds = start + 1;
clip.inPoint = inPoint;
end = new Time();
end.seconds = start + clip.duration.seconds - 1;
clip.end = end;
//
start = clip.end.seconds;
$.writeln(clip.name);
}
After setting inPoint i have this bug in timeline:
so when i try to get last inserted clip:
clip = seq.videoTracks[0].clips[(seq.videoTracks[0].clips.numItems - 1)];
i get first one due to this phantom clip in audiotrack o_O
is there any way to get inserted clip another way or how can i avoid that phantom added clip?
I've applied same trim to audio track also and it fixed issue:
clipAudio = seq.audioTracks[0].clips[(seq.audioTracks[0].clips.numItems - 1)];
Copy link to clipboard
Copied
UPD, after setting inPoint and end i have this:
video track trimmed as expected, audio not. outPoint doesn't work at all...
Copy link to clipboard
Copied
Which one is the phantom; the audio clip?
Copy link to clipboard
Copied
check red circle on screenshot in 1st post
Copy link to clipboard
Copied
Yes, you'd circled the audio clip; none of your code references audio tracks, which is what I found confusing.
Copy link to clipboard
Copied
you can try to run code, just replace file paths to real files.
Copy link to clipboard
Copied
this only happens when I use inPoint adjustment...
Copy link to clipboard
Copied
That's what happening, is there any way to avoid that bug?
Copy link to clipboard
Copied
I've applied same trim to audio track also and it fixed issue:
clipAudio = seq.audioTracks[0].clips[(seq.audioTracks[0].clips.numItems - 1)];
Copy link to clipboard
Copied
That fixed phantom audio track, but i'm still unable to get last inserted video... Looks like i have to search it by name rather than getting last inserted clip...
Copy link to clipboard
Copied
Send me your 'attempting to get last inserted video' code, along with a .prproj containing a representative sequence?
Copy link to clipboard
Copied
clip = seq.videoTracks[0].clips[(seq.videoTracks[0].clips.numItems - 1)];
this one doesn't work correctly after setting inPoints... Now as a solution I'm getting inserted clip by it's name...
Copy link to clipboard
Copied
[I'd need the .prproj, and further code context, to provide meaningful guidance...]