Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
FCE Timecode Display Plugin. Note that this information is probably out of date. It is being added here for reference/archival purposes and relates to a blog post from 2005
// FCE Timecode Display - by PieroF and i5m - v3.0.1 - 01-Feb-2005
// ========
// This plugin is freeware. Do what the hell you want with it.
// =======
// Get in touch: /
// ============
// To install this plugin simply place in your FCE plugins directory in your home folder
// In FCE 3 this is:
// ~/Library/Preferences/Final Cut Express User Data/Plugins
// Then look for the "PieroFi5m" folder under the Video Filters menu.
// Alternative install locations (as an Admin user) include:
// /Library/Application Support/Final Cut Express Support/Plugins
// or CTRL+click on the Application package, select Get Info and add the plugin that way.
// This will make the plugin available for all users of a machine. The /Library location is
// preferred since it *shouldn't* be affected by product updates. Should the plugin fail to
// show up try installing in the Users folder as above.
// ============
// This plugin displays timecode formats for PAL (25fps) and NTSC (29.97fps).
// In the case of NTSC drop-frame and non-drop frame timecode is indicated by "df" or "ndf"
// The is (currently) no way of choosing a different timecode format that the clips default
// Various options are available for configuring the display.
// =======
// 3.0.1. Corrected name of Delta from IN/OUT to more accurately reflect what it does, i.e. displays handle size
// 3.0 Additional features by PieroF - 27-Jan-2006 (marked //PF3): //PF3
// 1. Added display of Clip Start & End Timecode: [xx:xx:xx:xx] //PF3
// 2. Added display of handles size: ±xx:xx:xx:xx (origin: IN & OUT) //PF3
// 3. Added Control for selecting IN & OUT (in place of 1, 2, all) //PF3
// 4. Added Control for selecting Start & End //PF3
// 5. Added Control for selecting handles size //PF3
// 6. Moved controls to a better position //PF3
// 7. Disabled Control for Left, Center, Right Alignment, ONLY WHEN Text Display = Inline //PF3
// 8. Modified Alpha handling: removed AlphaType(kblack) to avoid side effects (see code) //PF3
// TechNote: Used GetLimits to get the offset of the IN point and the total length of the clip //PF3
// By combining them with the infos from GetTimeCode, both the Start and the End //PF3
// (physical) timecodes of the clip can be computed. //PF3
// In the Viewer GetTimeCode returns values as if IN=Start and OUT=End //PF3
// In the Canvas GetTimeCode values refer to the actual IN and OUT points //PF3
// 2.2 Adds in ability to display text Stacked or inline by i5m - 21-Nov-2005
// 2.1 Additional features by PieroF - 19-Nov-2005
// 1. Use of Matte in Place of Screen - last line //PF
// 2. Added Control for Left, Center, Right Alignment //PF
// 3. Added Control for selecting 1, 2 or all the output lines //PF
// 4. Added Control for Line Spacing //PF
// 2.0 Version 2 adds the Start and End timecodes (Above and Below) the current frame's timecode
// Unfortunately (techy info) I can't find a way of using Drawstringplain with three text strings
// which means the slower drawstring and image buffer routine has to be used
// Shouldn't be a problem as you shouldn't be rendering this anyway. Should you?! Some of the
// original comments have been removed, get v1 for those if interested
// ========
// All my notes and comments are included
// With inspiration from and thanks to:
// This replaces the previous Timecode Display v3
// scriptid "FCE Timecode Display -PieroFi5m -v3.0.1 01-Feb-2006" //DO NOT LOCALIZE
filter "FCE Timecode Display v3.0.1", 120;
group "PieroFi5m";
// AlphaType(kblack); // removed because Alpha remained Black even AFTER removing the filter!! //PF3
// This required unnecessary RENDERING of the clip even after removing this filter! //PF3
// ...or: alternatively I had to manually reset Alpha to None in the clip Properties: annoying //PF3
// After removal, Alpha is unchanged (None/Ignore) and this filter works fine anyway... //PF3
input info, "Refer to source for further info", Label, "string"; //PF
input wantCurrent, "Current TimeCode", CheckBox, 1; //PF
input wantINOUT, "IN/OUT TimeCode xx:xx", CheckBox, 1; //PF3
input wantStartEnd, "Media Limits TimeCode [xx:xx]", CheckBox, 0; //PF3
input wantDelta, "Media Handle Size from IN/OUT ±xx:xx", CheckBox, 0; //PF3
input fontname, "Font", FontList, "", "str";
input fontsize, "Size", slider, 11, 8, 100 detent 11;
input lineSpace, "Text Spacing", slider, 1, 0, 2; //PF
input center, "Reference Point", point, 0, 0; //PF
input fontcolor, "Font Color", color, 255, 255, 255, 255;
input stack, "Text Display", popup, 1, "Stacked", "Inline";
input justify, "Justify", popup, 2, "Left", "Center", "Right"; //PF
Invalentireitem //Used to reset each frame
//RenderEachFrameWhenStill //not needed, stills won't have timecode
code // any variable defined in the code section should resest each frame
if stack==2; justify=2; end if; // Justify applies only is Stacked //PF3
point centeroftm, framesize;
string textStartTC, textEndTC, textTC, textDF, textFR, textTCstring;
float clipTC, clipFR, clipDF, clipDuration, clipStartTC, clipEndTC;
float xdelta, ydeltaFirst, ydeltaLast, ydeltaCurrent, Lines; //PF
float glDuration, glOffset, yDeltaCorrect, xDeltaFactor, tracking; //PF3
string textStartClip, textEndClip, textStart, textEnd; //PF3
string textDeltaStart, textDeltaEnd; //PF3
float height, ascent, descent; // unused but necessary for MeasureString //PF3
float widthStart, widthCurrent, widthEnd; //PF3
yDeltaCorrect = 0.35; // to center output vertically //PF3
xDeltaFactor = 2; // to set horizontal gap in Inline //PF3
dimensionsof(dest, framesize.x, framesize.y);
centeroftm = framesize;
centeroftm *= center;
image bufferTC[framesize.x][framesize.y];
//Don't think below is needed
//setpixelformat (bufferTC, kformatRGB255);
//channelFill(destImage, alphaValue, red, green, blue)
channelFill(BufferTC, 0, 255, 255, 255);
fontcolor.a = 255;
fontsize /= 320/framesize.x;
tracking = 2 * (framesize.x/720); //PF3
setTextjustify(justify==1?kleftjustify:(justify==2?kcenterjustify:krightjustify)); //PF
GetTimeCode(Clip1, clipTC, clipFR, clipDF);
//clipTC -= frame/(fieldprocessing+1);
//The above line is from
//recommended for field/frame errors, especially wrt to NTSC.
//Can't get to work though, probably me not using frame properly.
// GetLimits returns: //PF3
// duration (float) = total duration of clip (start to end - NO in/out) //PF3
// offset (float) = IN point relative to clip start //PF3
getLimits(Clip1, glDuration, glOffset); //PF3
clipDuration = duration
clipStartTC = clipTC - (clipDuration * Ratio)
clipEndTC = clipTC + (clipDuration - (clipDuration * Ratio)) -1
//duration * ratio should give the frame.
// NOTE: when in the Canvas, ratio refers to the interval IN to OUT //PF3
// clipStartTC is the timeCode of the IN point //PF3
// The following evaluates textStart/EndClip and textDeltaStart/End //PF3
// Since glOffset is the offset of the IN point relative to the clip Start //PF3
// Then, clipStartTC - glOffset = timeCode of the clip Start //PF3
numToString(clipStartTC - glOffset, textStartClip, k25fps); //PF3
numToString(-glOffset, textDeltaStart, k25fps); //PF3
numToString(clipStartTC - glOffset + glDuration - 1, textEndClip, k25fps); //PF3
numToString(glDuration - clipDuration - glOffset, textDeltaEnd, k25fps); //PF3
if clipFR == 25;
numtostring(clipTC, textTC, k25fps);
textDF ="";
numtostring(clipStartTC, textStartTC, k25fps);
numtostring(clipEndTC, textEndTC, k25fps);
end if;
if clipFR == 29; //for some reason my test NTSC clips are 29fps as reported by gettimecode
if clipDF == 0;
numtostring(clipTC, textTC, k30fps);
textDF= " ndf";
numtostring(clipStartTC, textStartTC, k30fps);
numtostring(clipEndTC, textEndTC, k30fps);
numtostring(clipTC, textTC, k30df);
textDF= " df";
numtostring(clipStartTC, textStartTC, k30df);
numtostring(clipEndTC, textEndTC, k30df);
end if;
end if;
dest = src1; //set to stop fce being stupid
numtostring(clipFR, textFR, 0);
textTCstring = textTC + " @ " + textFR +"fps" + textDF;
// The following section is new: //PF3
// it prepares textStart and textEnd according to the new control values //PF3
// Cannot use more compact code since ( ? : ) does not work for strings... //PF3
textStart = ""; //PF3
textEnd = ""; //PF3
if wantINOUT; //PF3
textStart = textStartTC; //PF3
textEnd = textEndTC; //PF3
end if; //PF3
if wantDelta; //PF3
if (glOffset != 0); //PF3
if textStart!=""; //PF3
textStart = "-" + textDeltaStart + " " + textStart; //PF3
else; //PF3
textStart = "-" + textDeltaStart; //PF3
end if; //PF3
end if; //PF3
if (glDuration != clipDuration); //PF3
if textEnd!=""; //PF3
textEnd = textEnd + " +"+ textDeltaEnd; //PF3
else; //PF3
textEnd = "+"+ textDeltaEnd; //PF3
end if; //PF3
end if; //PF3
end if; //PF3
if wantStartEnd; //PF3
if (glOffset != 0 or (not wantINOUT)); //PF3
if textStart!=""; //PF3
textStart = "[" + textStartClip + "] " + textStart; //PF3
else; //PF3
textStart = "[" + textStartClip + "]"; //PF3
end if; //PF3
end if; //PF3
if (glDuration != clipDuration or (not wantINOUT)); //PF3
if textEnd!=""; //PF3
textEnd = textEnd + " [" + textEndClip + "]"; //PF3
else; //PF3
textEnd = "[" + textEndClip + "]"; //PF3
end if; //PF3
end if; //PF3
end if; //PF3
//The following code evaluates the string width of Start, End and TC //PF3
//MeasureString(string(I), spacing(I), width(O), height(O), ascent(O), descent(O), aspect(I)): //PF3
measurestring(textStart, tracking, widthStart, height, ascent, descent, aspectOf(dest)); //PF3
measurestring(textTCstring, tracking, widthCurrent, height, ascent, descent, aspectOf(dest)); //PF3
measurestring(textEnd, tracking, widthEnd, height, ascent, descent, aspectOf(dest)); //PF3
lines = wantCurrent + ((wantINOUT or wantStartEnd or wantDelta) ? 2 : 0); //PF3
ydeltaFirst = yDeltaCorrect + lineSpace*(lines==3 ? -1.5 : (lines==2 ? -1 : 0)); //PF3
ydeltaLast = yDeltaCorrect + lineSpace*(lines==3 ? 1.5 : (lines==2 ? 1 : 0)); //PF3
ydeltaCurrent = yDeltaCorrect; //PF3
if stack == 2
ydeltaFirst = yDeltaCorrect;
ydeltaLast = yDeltaCorrect;
ydeltaCurrent = yDeltaCorrect;
xdelta = linespace * fontsize * xDeltaFactor + wantCurrent*widthCurrent/2 + (widthStart>widthEnd ? widthStart : widthEnd)/2; //PF3
end if;
//Below is reminder for me
//DrawString(string, h, v, spacing, image, color, aspect)
if (wantINOUT or wantStartEnd or wantDelta);
drawstring(textStart, centeroftm.x-xdelta, centeroftm.y+ydeltaFirst*fontsize, tracking, bufferTC, fontcolor, aspectof(dest));
drawstring(textEnd, centeroftm.x+xdelta, centeroftm.y+ydeltaLast*fontsize, tracking, bufferTC, fontcolor, aspectof(dest));
end if; //PF3
if wantCurrent or not(wantINOUT or wantStartEnd or wantDelta);
drawstring(textTCstring, centeroftm.x, centeroftm.y+ydeltaCurrent*fontsize, tracking, bufferTC, fontcolor, aspectof(dest));
end if; //PF3
matte(bufferTC, dest, dest, 1, kalpha) //PF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment