ExtendScript Premier Pro Automation

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>// 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);
</code>
<code>// 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); </code>
// 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

New contributor

satish K is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật