If I understand what you want this should do all but the final save. Note it could take a long time if there are a lot of frames.
// this requires a document with a video layer be the activeDocument
// and the video layer be the activeLayer. It also requires the timeline panel be visible
var vidDoc = app.activeDocument;
var dupDoc = vidDoc.duplicate();
dupDoc.flatten();
app.activeDocument = vidDoc;
var numerOfFrames = GetFrameCount();
for( var f =0; f< numerOfFrames; f++ ){
GotoNextFrame();
vidDoc.selection.selectAll();
executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );// jump frame to new layer
vidDoc.activeLayer.duplicate(dupDoc);
vidDoc.activeLayer.remove();
app.activeDocument = dupDoc;
dupDoc.activeLayer.blendMode = BlendMode.LIGHTEN;
dupDoc.flatten();
app.activeDocument = vidDoc;
}
function GetFrameCount(){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID( "frameCount" ) );
ref.putClass( stringIDToTypeID( "timeline" ) );
var desc = new ActionDescriptor();
desc.putReference( charIDToTypeID( 'null' ), ref );
var resultDesc = executeAction( charIDToTypeID( 'getd' ), desc, DialogModes.NO );
return resultDesc.getInteger( stringIDToTypeID( "frameCount" ) );
};
function GotoNextFrame() {
var thatWorked = undefined;
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Mn " ), charIDToTypeID( "MnIt" ), stringIDToTypeID( "timelineGoToNextFrame" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
thatWorked = true;
}
catch(e) {
thatWorked = false;
alert('All frames are processed.');
}
return thatWorked;
};