This is the project screenshot,
I am working on Premier Pro Automation Project where I need to make my work simple by using extend script. So I can just replace paths for media and render it automatically.
My Requrements:
I want to replace Video in V3
Add fade in transition in the markers in V3
Change last three text layers
Change subtitle
Then render to specific path
Sequence Name: 60 Johnstone Street, Peakhurst
New Video Path = D:/Satish Kumar K/A4 NISD/PP Template/Johnstone-20240920T055442Z-001/Johnstone/Assests/Friends_On_A_Meadow_original_177140.mov
My code is below:
// Replace Video in V3
var newMediaPath = "D:/Satish Kumar K/A4 NISD/PP Template/Johnstone-20240920T055442Z-001/Johnstone/Assests/Friends_On_A_Meadow_original_177140.mov";
function replaceClipInV3(newMediaPath) {
var sequence = app.project.activeSequence;
if (!sequence) {
$.writeln("No active sequence found.");
return;
}
var videoTrack = sequence.videoTracks[2]; // V3 is index 2
var clip = videoTrack.clips[0]; // Assume first clip on V3
if (clip) {
clip.projectItem.replaceFootage(newMediaPath);
$.writeln("Replaced clip on V3 with " + newMediaPath);
}
}
replaceClipInV3(newMediaPath);
// Add Fade-In Transitions
function addFadeInToMarkers(trackIndex) {
var sequence = app.project.activeSequence;
var videoTrack = sequence.videoTracks[trackIndex];
var clip = videoTrack.clips[0]; // Assume first clip on V3
for (var j = 0; j < sequence.markers.numMarkers; j++) {
var marker = sequence.markers.getMarkerAt(j);
if (clip.start.seconds <= marker.start.seconds && clip.end.seconds >= marker.start.seconds) {
clip.components[1].properties[0].setValueAtTime(0, marker.start.seconds); // Apply fade-in at marker
$.writeln("Applied fade-in at marker.");
}
}
}
addFadeInToMarkers(2); // V3 is index 2
// Change Last Three Text Layers
function updateTextLayers(newTexts) {
var sequence = app.project.activeSequence;
var textTrack = sequence.videoTracks[3]; // Assume text layers are on V4
var clipCount = textTrack.clips.numItems;
for (var i = clipCount - 3; i < clipCount; i++) {
var clip = textTrack.clips[i];
clip.components[1].properties[0].setValue(newTexts[i - (clipCount - 3)]);
$.writeln("Updated text layer.");
}
}
var newTexts = ["New Text 1", "New Text 2", "New Text 3"];
updateTextLayers(newTexts);
// Change Subtitle
function updateSubtitle(newSubtitle) {
var sequence = app.project.activeSequence;
var subtitleTrack = sequence.videoTracks[4]; // Assume subtitles are on V5
var subtitleClip = subtitleTrack.clips[0]; // Assume first clip is the subtitle
subtitleClip.components[1].properties[0].setValue(newSubtitle);
$.writeln("Updated subtitle.");
}
updateSubtitle("New subtitle text.");
Can anyone help me to fix the error and it should run smoothly.
My main aim is to Replace video, Add facein effects in the markers, Change Text layer, change subtitles,add music and then render to specific path.
Thank you and looking forward for your answers on this.
It showed me
"ReferenceError: clip.projectItem.replaceFootage is not a function"
THen I changed the codes to below:
// Define the new media path
var newMediaPath = "D:/Satish Kumar K/A4 NISD/PP Template/Johnstone-20240920T055442Z-001/Johnstone/Assests/Friends_On_A_Meadow_original_177140.mov";
function replaceClipInV3(newMediaPath) {
var sequence = app.project.activeSequence; // Get the active sequence
if (!sequence) {
$.writeln("No active sequence found.");
return;
}
// Access V3 track (track index 2)
var videoTrack = sequence.videoTracks[2];
if (videoTrack.clips.numItems > 0) {
var clip = videoTrack.clips[0]; // Access the first clip on V3
var projectItem = clip.projectItem; // Get the ProjectItem of the clip
// Check if the projectItem is valid and replace footage
if (projectItem) {
projectItem.replaceFootage(newMediaPath);
$.writeln("Replaced clip in V3 with " + newMediaPath);
} else {
$.writeln("No ProjectItem found for the clip in V3.");
}
} else {
$.writeln("No clips found in V3.");
}
}
// Replace the clip in V3
replaceClipInV3(newMediaPath);
But not able to srt this out .
Thank you