Does exportFramePNG() still work??
I'm aware this is part of the QE DOM which isn't (for some reason) officially supported - shame because it seems to be able to do a lot of useful things!
I want a script I can run which will iterate through the current timeline, and for any track items whose name includes "preview", output a thumbnail frame of that clip to a folder. (I'm working with a lot of temp stock, and when the time comes to swap out all the items the client's chosen, it's a huge drag to compile a list manually that I can send to the person who's buying the stock. I want thumbnails not just names, to minimise the problem of them buying the wrong clip.)
QE seems to have a exportFramePNG() function, referenced here. That code suggests it takes two parameters: a timecode, in the format HH_MM_SS_FF, and a file path. So I'd expect something like this to work, on Windows - but it doesn't.
function secsToTimecode(sq, tm, d) { // hacky way to return a timecode with underscores
if (d == '') d = ":";
tps = 254016000000;
tb = sq.timebase; // ticks per frame
fps = tps/tb;
// frames
ff = Math.round((tm - Math.floor(tm)) * fps);
if (ff < 10) ff = '0' + ff;
// secs
ss = Math.floor(tm)%60;
if (ss < 10) ss = '0' + ss;
// mins
mm = Math.floor(tm/60)%60;
if (mm < 10) mm = '0' + mm;
// hrs
hh = Math.floor(tm/3600)%60;
if (hh < 10) hh = '0' + hh;
return hh + d + mm + d + ss + d + ff;
}
app.enableQE();
sqq = qe.project.getActiveSequence(); // QE version!
op = sqq.outPoint;
sq = app.project.activeSequence;
videoTracks = sq.videoTracks;
var outputPath = new File("C:\Users\Username\Desktop\frames");
for (i = 0; i < videoTracks.numTracks; i++) {
trk = videoTracks[i];
for(j = 0; j < trk.clips.numItems; j++) {
nm = trk.clips[j].name ;
if (nm.toUpperCase().indexOf("PREVIEW") != -1) { // Preview clip
if (trk.clips[j].start.seconds < op.secs) { // ignore any clips after end of work area
$.writeln(nm + ", T: " + trk.clips[j].start.seconds + ", Dur: " + trk.clips[j].duration.seconds); // This works as expected
tm = secsToTimecode(sq, trk.clips[j].start.seconds + (trk.clips[j].duration.seconds/2), '_'); // pick an export point that's halfway through the clip
sqq.exportFramePNG(tm, outputPath.fsName + '\\' + nm + ".png"); // This does nothing!
}
}
}
}
