Loading...
Loading...
This skill should be used when the user asks to "make a countdown timer video", "create a countdown animation", "build a stream starting soon countdown", "do an event/launch/sale countdown", "animate a mm:ss or dd:hh:mm:ss timer", "add digit roll/flip transitions to a counter", or "loop a countdown background". Covers frame-accurate (drift-free) timers, digit flip/roll motion, time formatting, and a configurable duration prop.
npx skill4agent add iart-ai/tiktok-video-skills countdown-videosetIntervalsetInterval(fn, 1000)| Context | Authoritative clock | Remaining time |
|---|---|---|
| Remotion render | | |
| Web (live page) | | |
| To a fixed date | | |
useCurrentFrame()N/fpsimport { useCurrentFrame, useVideoConfig } from "remotion";
export const Countdown: React.FC<{ durationInSeconds: number }> = ({
durationInSeconds,
}) => {
const frame = useCurrentFrame();
const { fps } = useVideoConfig();
// remaining seconds, clamped at 0 — ceil so "1" shows for its full second
const elapsed = frame / fps;
const remaining = Math.max(0, Math.ceil(durationInSeconds - elapsed));
return <div style={{ fontVariantNumeric: "tabular-nums" }}>{formatMMSS(remaining)}</div>;
};durationInSecondsdurationInFramesdurationInSeconds * fpsperformance.now()const start = performance.now();
let lastShown = -1;
function tick(now) {
const remaining = Math.max(0, Math.ceil(duration - (now - start) / 1000));
if (remaining !== lastShown) { render(remaining); lastShown = remaining; }
if (remaining > 0) requestAnimationFrame(tick);
}
requestAnimationFrame(tick);Date.now()Math.max(0, target - Date.now())references/countdown-cookbook.md00d 00h 05mconst pad = (n) => String(n).padStart(2, "0");
const formatMMSS = (s) => `${pad(Math.floor(s / 60))}:${pad(s % 60)}`;
const formatDHMS = (s) => {
const d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600);
const m = Math.floor((s % 3600) / 60), sec = s % 60;
return `${pad(d)}:${pad(h)}:${pad(m)}:${pad(sec)}`;
};| Format | Use | Drop fields when |
|---|---|---|
| stream "starting soon", short timers (<1h) | — |
| flash sale, same-day event | hide |
| launch / multi-day countdown | hide leading 0 units for cleaner read |
font-variant-numeric: tabular-nums-digit × digitHeight.reel { height: 1em; overflow: hidden; }
.reel .col { transition: transform .45s cubic-bezier(.22,1,.36,1); }
/* col holds stacked 0..9; shift by -value em */references/digit-flip.mdloopFramesframe % loopFramesreferences/countdown-cookbook.mduseCurrentFrame()performance.now()setInterval00:00durationInFrames === durationInSeconds × fpstabular-numsPackaged helper (): tile your stills withscripts/, then assert the encode withscripts/contact-sheet.sh sheet.png f-hook.png f-mid.png f-end.png. Seescripts/probe-mp4.sh out.mp4 [WxH] [fps].scripts/README.md
<Composition>schemadefaultPropsdurationInSecondsuseCurrentFrame()setIntervalDate.now()Math.random()durationInFrames = durationInSeconds * fpsout/*.mp4# Stills at start / mid / end — WITH SHIPPED PROPS (the real duration you'll render)
npx remotion still Countdown out/f-start.png --frame=0 --props='{"durationInSeconds":300}'
npx remotion still Countdown out/f-mid.png --frame=N --props='{"durationInSeconds":300}'
npx remotion still Countdown out/f-end.png --frame=L --props='{"durationInSeconds":300}' # L = durationInFrames-1
# Inspect each PNG — the digits must read EXACTLY the frame/fps math:
# - at frame N, displayed = ceil(durationInSeconds - N/fps) (e.g. 300s @ 30fps, frame 4500 → 150s → "02:30")
# - last frame reads 00:00 (or the end-state hold); no drift, no off-by-one second
# - tabular-nums: layout does not jitter between frames
# - 9:16 safe area: the timer + brand block sit clear of top ~12% and bottom ~20-35% UI and the right action rail
npx remotion render Countdown out/countdown.mp4 --props='{"durationInSeconds":300}' # encode once digits verify
npx remotion render Countdown out/demo.gif --codec=gif # README proof clipnpx remotion compositionsdurationInFramesfpsceil(durationInSeconds - N/fps)setIntervalDate.now()tabular-numsdurationInSecondsdefaultPropsreferences/countdown-cookbook.md<Countdown>references/digit-flip.md