Software Ad Motion
Rebuild the supplied video as editable scenes that match it frame by frame. The actual reference frames and timestamps are the evidence; every position, colour, size, timing and easing should come from a measurement, not from a guess. Combine Motion2Code's visual reconstruction and deterministic timeline with Reanimate's measured property specification, easing fitting and correction loop.
A skill coordinates the agent and its tools; it does not recover hidden source layers, fonts, 3D models or audio stems automatically. Report what was measured and what was approximated.
Defaults
- Input: a local MP4/MOV/WebM/GIF or an accessible reference the user supplies. If a link cannot be obtained, request the actual video while preparing the project.
- Mode: faithful reconstruction. Preserve visible copy, layout, branding, scene order, duration, opening, pauses and CTA unless the user asks to change them.
- Output: editable motion source, rendered MP4 when supported, timestamped frame evidence and a comparison report. An HTML animation here is a renderable video scene, not a website.
- Engine: HTML/DOM + SVG with one deterministic
window.anim.seek(t). Use a paused GSAP timeline when available; pure frame-time functions otherwise. Preserve an established Remotion/Canvas/Three.js stack with a deterministic adapter. The bundled renderer drives the HTML contract. - Loop: off. Reproduce a loop only if present or requested. Never round away the last fraction of a second.
- Assets: declared logos, fonts, screenshots, product recordings and textures are allowed; record provenance and editability. Never embed the full reference video, a full-frame PNG sequence or a dense frame trace as a substitute for reconstruction.
- Audio: preserve supplied/reference audio when requested, via an explicit
--audioinput. Visual comparison does not verify sound. - Iterations: work scene by scene. Fix the largest measured divergence, re-render that scene, re-measure. Budget about five substantive rounds per scene; finish with one complete comparison. Never lower tolerances silently.
Do not ask for confirmation of routine implementation choices. Ask only for information that materially changes the task (missing reference, ambiguous product replacement).
Toolbox
Set SKILL_DIR to this file's directory. Python 3.10+, FFmpeg/ffprobe, numpy, Pillow, Playwright (scripts/requirements.txt). Run python "$SKILL_DIR/scripts/selftest.py" once in a new environment (about one minute).
| Tool | Use it to |
|---|---|
analyze_video.py | Decode every frame at its timestamp, with explicit colour conversion; contact sheets; cut candidates |
inspect_frame.py | Zoom into a region with pixel rulers: read small text, measure exact coordinates; --candidate shows reference / render / difference |
sample_color.py | Exact colours (point or box median, most frequent values); series of luma/opacity over frames for fades |
track_element.py | Measure an element's position/scale in every frame (subpixel template matching); series for easing; --candidate gives per-frame px error |
fit_easing.py | Fit cubic-Bezier (incl. After Effects Easy Ease) or a damped spring to a measured series |
render_video.py | Render at every reference timestamp; partial ranges, parallel workers, motion blur, supersampling, font audit, tagged MP4 |
compare_frames.py | Strict full comparison: gates, codec noise floor, SSIM, per-scene error maps, timeline, worst frames |
diagnose_offsets.py | Per scene: how many frames early/late, and how many px shifted (whole frame and regions) |
1. Establish the reference
Read the destination project's instructions, assets and animation libraries. Record in motion-spec.json: source file, time range, dimensions, timestamps, duration; mode (faithful/adapted) and intentional changes; deliverables and stack; asset inventory (supplied / static crop / reconstructed / approximate / unavailable); missing fonts or unreadable text and their effect.
For a selected time range, keep the mapping to the original time. Decode before trimming (frame-accurate filtering, not keyframe stream copy). If no reference is supplied, prepare the project and request one; do not claim a reconstruction.
Read references/software-ad-workflow.md (shot decomposition, spec structure, fonts) and references/runtime-and-verification.md (command contracts, colour, metrics). If the ad looks like After Effects output (motion blur, Easy Ease, track mattes, glows), read references/after-effects-to-web.md.
2. Study the video
python "$SKILL_DIR/scripts/analyze_video.py" reference.mp4 --out work/study
- Check
decode_colorin the output. An untagged source is decoded with an assumed matrix (BT.709 for ≥720p); confirm with a known colour (white UI, brand colour) and override with--assume-matrixif needed. Wrong colour decoding shifts every hex value you measure. - Open every contact-sheet page for the overview. Then zoom, because image viewers downscale frames and hide small text and 1–2 px offsets:
python "$SKILL_DIR/scripts/inspect_frame.py" work/study/reference.json --frame 120 --grid 100 --out work/look/f120.png
python "$SKILL_DIR/scripts/inspect_frame.py" work/study/reference.json --frame 120 --box 40,30,260,60 --out work/look/logo.png
- Read colours with
sample_color.py(never estimate hex values by eye, never use the palette bins as exact values). - Treat cut and palette results as hints; review fast transitions, flashes and holds frame by frame.
- Preserve the source frame rate as a rational and the actual timestamps for VFR. Do not silently crop, resize, tone-map, drop frames or normalize audio offsets.
3. Measure the motion specification
Complete motion-spec.json before substantial animation work: one entry per scene and per animated property (element, layer, box, transform origin, clipping; property, from/to, start, duration, easing, evidence frames; measured / estimated / supplied / intentional), plus visible events and regions to verify separately (product UI, small text, logo, cursor, CTA).
Measure trajectories instead of reading them by eye:
python "$SKILL_DIR/scripts/track_element.py" work/study/reference.json --template-frame 140 \
--box 610,380,300,90 --frames 100:160 --scales 0.8:1.2:0.01 \
--out work/track/card.json --series-dir work/series/card --preview work/track/card.png
python "$SKILL_DIR/scripts/fit_easing.py" work/series/card/cy.json --out work/easing/card-y.json
python "$SKILL_DIR/scripts/sample_color.py" work/study/reference.json --frames 20:50 --box 600,300,6,6 \
--opacity-between "#0b1124" "#ffffff" --series work/series/title-opacity.json
- Pick a template box with visible detail in a settled frame. View the
--previewsheet; drop frames listed as unreliable (hidden, blurred, reshaped). - Fit one property and one motion phase at a time; include peak and settle for overshoot. If
damped-springwins, implement the spring (stiffness/damping given) or itscss_linear. Keep fit parameters, RMSE and evidence in the spec. A close fit does not prove the original implementation. - Mark unresolved observations instead of inventing text or fonts. Never replace legible UI labels with decorative bars.
4. Build: still frames first, then motion
Start from assets/starter/index.html or adapt the destination project.
- Layout pass. For each scene, choose a settled frame and make it match before animating: geometry, colours, typography, shadows, radii. Iterate with
render_video.py --frames N:N+1andinspect_frame.py --candidateuntil the zoomed difference is only antialiasing. - Typography. Identify and load the real font (see the font workflow in
references/software-ad-workflow.md). The renderer audits which platform font draws each text node and warns on fallback; use--strict-fontsonce fonts are settled. - Motion pass. Place each property at its measured absolute time with its fitted easing. Preserve overlaps and holds.
- Effects pass. Motion blur (
--motion-blur-samples), blur, glow, grain — only where observed.
Implementation rules:
- Separate named groups/components for panels, typography, logos, pointers, effects and cameras; camera motion separate from object motion; transform origins explicit.
- Every visual property is a pure function of
t; seeking in any order gives the same frame. One clock; no wall-clock timers, uncontrolled CSS animations, real-time physics or unseeded randomness. - Load fonts and assets before readiness; treat failures as errors.
- Rebuild UI content as editable elements when feasible; mark raster crops/footage as raster.
window.anim = {
width, height, duration,
seek(t) { /* every visible state is a pure function of seconds; may return a Promise */ },
pause() { /* stop preview playback */ }
};
document.documentElement.dataset.ready = "1"; // after fonts, images, media, first frame
With ?external=1, disable preview playback. For hands-on tuning, the starter's preview accepts ?ref=path/to/reference.json to overlay the reference in difference mode (keys o, space, arrows).
5. Render, compare, diagnose
python "$SKILL_DIR/scripts/render_video.py" project/index.html \
--reference work/study/reference.json --out work/render-01 --workers 4
python "$SKILL_DIR/scripts/compare_frames.py" work/study/reference.json work/render-01/frames.json \
--spec motion-spec.json --regions project/regions.json --noise-floor --out work/compare-01
python "$SKILL_DIR/scripts/diagnose_offsets.py" work/study/reference.json work/render-01/frames.json \
--spec motion-spec.json --regions project/regions.json --out work/compare-01/offsets.json
- Read
report.html: the error timeline shows which scene to fix; each scene's mean error map shows where error persists (bright static areas = layout/colour/type; bright edges along a path = timing/trajectory); worst-frame pairs show what. diagnose_offsets.pyturns that into actions: "cta: 2 frames late" → move those keyframes 2 frames earlier; "hook-title dx=+3" → move it 3 px left. It is a diagnosis only; the comparison never shifts time or space.track_element.py --candidatecompares a single element's trajectory frame by frame in pixels.--noise-floormeasures what one H.264 pass alone changes on the reference and gates on limit + floor, so codec noise does not count as reconstruction error. It is reported separately and is an estimate.- While iterating, render and compare only the scene you changed (
--frames A:Bor--start/--end); such reports are markedpartial_and never count as final. - For delivery, add
--mp4 output/ad.mp4(tagged BT.709;--audioto mux sound), then analyze the MP4 in a new directory and compare it too.
Distinguish: (1) coverage valid, (2) exact decoded RGB equality, (3) within declared tolerances (state whether floor-adjusted), (4) human visual review, (5) encoded delivery checks. Never call an error metric a percentage of fidelity: MAE 0.02 is not "98 % identical".
6. Correct the worst causes, in this order
- Missing/wrong assets, fonts, scene boundaries, layer order.
- Geometry, clipping, camera framing, alignment (error maps,
diagnose_offsets, zoom). - Event timing, stagger, trajectory, easing (
diagnose_offsets, tracking, fits). - Colours, shadows, blur, motion blur, grain (
sample_color, zoom, SSIM).
Keep each round's source and evidence in new directories. Use full-frame diagnostics and named regions: a matching background must not hide a wrong icon, CTA or small label.
For adapted mode, record changed words, branding, assets and aspect ratio; evaluate preserved motion and layout separately; never report a whole-frame pixel pass against a different brand.
7. Deliver
Save the project, final video and evidence where the user asked. Report, in the user's language:
- What was reconstructed and any intentional adaptation.
- Duration, dimensions, frame rate and compared frame coverage.
- What actually ran: deterministic render, complete comparison (absolute or floor-adjusted gates), region checks, font audit, visual review, encoded-output and audio checks.
- Residual differences per scene with measured error and probable cause; unavailable assets and font substitutions.
- How to edit the key content and animation parameters.
Do not claim "pixel perfect" from a screenshot, an average, a contact sheet or a green runtime check; reserve exactness for decoded-pixel equality that actually occurred. A self-test on the starter does not prove fidelity on a real ad.
Supporting files
references/software-ad-workflow.md: scene/property spec, typography and font identification, UI, regions, adaptation.references/after-effects-to-web.md: translating After Effects/compositor behaviour (easing, springs, motion blur, mattes, blend modes, text units) to the web.references/runtime-and-verification.md: dependencies, colour pipeline, manifests, renderer options, metrics, noise floor, exports and limits.references/upstream.mdandreferences/licenses/: upstream revisions and MIT notices.assets/starter/index.html: deterministic editable example with a reference-overlay preview.scripts/: the tools above,motion_common.py(shared helpers) andselftest.py.