Communitygithub.com

kinopico-zhang/trip-video-skill

制作"地理行程长视频"(多段交通 + 飞机航线 + Google Earth Studio 云渲染 + 合成出片)的完整流水线。 当用户要为一条(可能全新的)旅行路线做 Earth Studio 视频时使用:地面导航查询(OSRM)、 飞机真实航路调研(Tavily)、渡轮/海路、esp 生成、CDP 自动化云渲染、帧合成、QC、编码与 NAS 交付。 已跑通的样例:清湖北站→深圳湾口岸→HKG→CEB→锡基霍尔(v17)。

trip-video-skill 是什么?

trip-video-skill is a Claude Code agent skill that 制作"地理行程长视频"(多段交通 + 飞机航线 + Google Earth Studio 云渲染 + 合成出片)的完整流水线。 当用户要为一条(可能全新的)旅行路线做 Earth Studio 视频时使用:地面导航查询(OSRM)、 飞机真实航路调研(Tavily)、渡轮/海路、esp 生成、CDP 自动化云渲染、帧合成、QC、编码与 NAS 交付。 已跑通的样例:清湖北站→深圳湾口岸→HKG→CEB→锡基霍尔(v17)。.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add kinopico-zhang/trip-video-skill

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Trip Video (Earth Studio Itinerary Long Video) Production Pipeline

This skill is a git repo (kinopico-zhang/trip-video-skill). Below, $T = repo root (local: ~/.claude/skills/trip-video → symlink ~/workspace/trip-video-skill). Convention: each route gets its own working directory (data json / esp / frames go there), scripts are invoked from $T. Deep details in $T/references/: case-study-v17.md (full v7→v17 postmortem, read before starting), presentation-rules.md (presentation rules, user confirmed do not regress). Full example: $T/examples/sz-hkg-ceb-siquijor/.

0. Pipeline Overview

Route Research (OSRM driving route / Tavily flight path / ferry route)          ← §1–§2
  ↓   Write per-route generation scripts (copy examples/) → per-segment .esp + flight_data.json   ← §3
Windows headless Chrome CDP Automation Earth Studio Cloud Rendering   ← §4
  ↓  siq_dl.mjs download mp4 → ffmpeg decode into base frames
src_frames/ (1-indexed f%05d.jpg)
  ↓  compose20.py compositing (route/vehicle/walking dashed line/labels/icons)
comp_frames/ (0-indexed) → qc + MAD flicker check            ← §5
  ↓  ffmpeg encode (crf 18)
scp nas:/share/Public/earth/ + dual-end md5                 ← §6

Data file flight_data.json (schema in examples' flight_data30.json): route per-vertex (lat,lon,alt,rt) + walk flag, samples 0.1s camera samples, frames per-frame vehicle kind/position/tangent, walks walking windows, emoji each vehicle sprite heading angle, named anchors (airport/ferry terminal/border crossing/start…), fps.

Environment: node≥22 (cdp scripts zero-dependency); Pillow via PYTHONPATH (local pointing to ~/workspace/google-earth/pylibs, machine has no system PIL); ffmpeg at /home/admin/.local/bin/ffmpeg; no numpy (everything with PIL); NAS via ssh alias nas, delivery directory /share/Public/earth/.


1. Ground Navigation Query (OSRM)

Driving segment geometry uses the public OSRM demo (Google Maps directions RPC unreachable under headless; OSRM follows the same road network):

# Driving route between two points (overview=full for full geometry); multiple points separated by semicolons to force via. Machine has no jq, extract coordinates with python
curl -s 'https://router.project-osrm.org/route/v1/driving/114.0354,22.6748;113.9350,22.5101?overview=full&geometries=geojson' \
  | python3 -c 'import json,sys; d=json.load(sys.stdin); json.dump(d["routes"][0]["geometry"]["coordinates"], open("route_SZ_raw.json","w"))'
# Result [[lon,lat],...] (note longitude first!), saved as route_<segment>_raw.json
  • Endpoint pinning: OSRM endpoints snap to the road surface, not to exact anchor points → _load_forced (implemented in examples' trip_v10.py) pins start/end to exact anchors: if distance >25m from anchor, insert; otherwise replace.
  • Water crossing validation: Sea-crossing bridges are legitimate elevated marine structures; use Natural Earth ne_50m_land point-in-polygon to check if a segment falls over water, distinguishing "elevated" from "OSRM erroneously routing around water".
  • Walking segments (through border hall → runway/gate → exit): 1–2s, measure distance on map, do not query road network; displacement uses ECEF chord Hermite platform curve (_walk_ckpt, zero speed at both ends, τ=0.3s).
  • Ferry/sea routes: OSRM has no ferry routes → query Tavily for ferry company/route/pier, draw route manually over sea.

2. Flight Route Query (Tavily Research → WPTS)

Flight paths must be researched with real data modeling, do not fake with great circle lines. Use tvly from §7 to find out five things:

  1. Departure runway and initial heading (example: HKG 07L/07R, track 073° east)
  2. Departure waypoint sequence (073°→BREAM right turn→ATTOL→SIKOU to avoid Lantau 934m peak)
  3. Cruise altitude and total distance (FL350=10668m, ~1790km)
  4. Route direction (along western coast of Luzon→Tablas Strait→west of Negros→Tanón Strait)
  5. Arrival runway and approach direction (CEB land 04, prevailing northeast wind)

Search keywords: "<DEP> <ARR> flight route waypoints", "<ICAO> departure chart SID"; cross-validate with flightradar24 route page, airport diagrams. Output = WPTS list in generation script (examples' flight10.py pattern: (lat, lon) + runway threshold/rotation point/each waypoint annotation), trajectory = Catmull-Rom spline through waypoints. Document research conclusions in script docstring with date.

3. Camera Design and esp Generation (per-route script)

Generator pattern (copy $T/examples/sz-hkg-ceb-siquijor/trip_v10.py): each segment gets one .esp + aggregated flight_data.json, library in $T/compose/ (flight.py/flight_v5.py: ll2ecef, CAL table, hermite, build_esp). Core math (all empirically validated, do not modify):

  • ES interpolation semantics: Cloud rendering = keyframes linearly interpolated in numeric space; altitude interpolated in CAL value (log) space, write kf using alt_to_value(); very large zoom segments (≥Mm pullback) must be interpolated in v_write space.
  • Camera basis vectors (look-at self-calculated, aligned to ES render within ≤1px): f=norm(poi−cam), r=norm(cross(f,norm(cam))), u=cross(r,f) (u=cross(f,r) gives upside-down image).
  • Top-down north-up: Camera directly above target, look-at target = camera ground point shifted north by 0.007·H (≈0.4° tilt, heading constant 0 to avoid jitter).
  • kf density: start at 0.1s sampling; tight motion timeline must have per-frame kf (0.1s+ linear interpolation compresses H zoom into polyline, 10Hz apparent speed pulse 1.6×).
  • Smooth camera motion = H zoom: camera translation uses du/df = c·s(f)·H(f) (s=ease at zero-speed endpoints) → screen speed independent of altitude; during cruise envelope method v(t)=COEF·H(t) (solve COEF from mileage equation) yields constant screen speed ~700px/s.
  • Large-span zoom interpolated in log space + sinease; multi-anchor use cubic Hermite + manual tangents (smoothstep resets speed to zero at each anchor causing stutter).
  • Bit-exact seams between segments: First frame camera state of next segment verbatim writes endpoint from adjacent segment's camera_state(); generator has built-in _seam_diff assertion < 1e-12 (kf difference must = 0; measured frame diff 1–16 leaves only cloud rendering noise).
  • Frame count trap: Always use int(round(T*FPS)) (int(4.1*30)=122≠123).

4. Earth Studio Cloud Rendering (CDP Automation)

Prerequisite: Windows Chrome --headless=new --remote-debugging-port=9222 --user-data-dir=C:\Users\admin\ChromeESAuto (Chrome 136+ must have dedicated user-data-dir) logged into ES; WSL2 mirrored network connects directly to http://localhost:9222.

node $T/cdp/nav_es.mjs                      # Restore/open ES + resize window 1920×1080 (viewport resets to 985px after each import/refresh, must re-run!)
node $T/cdp/siq_import.mjs 'C:\Users\admin\ChromeESAuto\seg0.esp'   # Import esp (Windows path)
node $T/cdp/siq_scrub_batch.mjs 45 45 15 …  # ArrowRight step through frames reading property panel (longitude/latitude/altitude) comparing to design values
node $T/cdp/render_submit.mjs "Seg0"        # DOM click to open render dialog + Submit (cloud render 1080p mp4, ~2 minutes/segment)
node $T/cdp/siq_poll.mjs "Seg0" 15          # Poll queue until delivered (API may take a few seconds to register after submit, "NONE"≠failure)
node $T/cdp/siq_dl.mjs get "Seg0"           # Download from queue modal; after done use `siq_dl.mjs close`

Three major CDP pitfalls (script has built-in workarounds, principles in case-study §4):

  • esp import: DOM.setFileInputFiles after must manually dispatch change event, otherwise ES fails silently; import only goes to memory not disk → Submit directly from live state.
  • Synthetic mouse click after import randomly fails → render button/Submit always use DOM el.click() (render_submit.mjs).
  • React controlled inputs occasionally refuse injected job name → submit with esp default name, poll and download by default name (siq_dl.mjs get must include job name, otherwise wrong file); bigstore direct link 404 don't use.
  • Property panel altitude display >350km reads 8–17% low (display bug, rendering path accurate, don't be misled).
  • Credentials not written to disk: login uses node $T/cdp/login2.mjs <password> (argv input).

5. Frame Assembly, Compositing, and Presentation Rules

# Decode (mp4 f00001 = t=0, 1-indexed)
/home/admin/.local/bin/ffmpeg -i seg0.mp4 -qscale:v 1 seg0_frames/f%05d.jpg
# Rename into src_frames/ sequentially by timeline (1-indexed contiguous)

# Composite (KEEP_WM=1 = keep Google logo, only delivery form)
cd <work directory>
FLIGHT_DATA=flight_data.json SRC=src_frames OUT=comp_frames KEEP_WM=1 \
  PYTHONPATH=<Pillow path> python3 $T/compose/compose20.py
FLIGHT_DATA=flight_data.json SRC=src_frames OUT=comp_frames \
  PYTHONPATH=<Pillow path> python3 $T/compose/compose20.py qc

# MAD flicker (192×108 grayscale adjacent frame difference): median≤14 static / 20–27 log zoom steps / >40 flicker
PYTHONPATH=<Pillow path> python3 $T/qc/mad_check.py comp_frames

Full presentation rules in $T/references/presentation-rules.md (user confirmed, do not regress), key points: logo must keep single version; walk = dynamic dashed line no person drawn; no trailing vehicle at end; icons strictly ∝1/alt (13500/alt, floor 0.12) + base map long side 150px equal size at same altitude; vehicle pre-wait + exact anchor stop (wait→stop→current order drawing).

compose20.py per-route edit points (everything else data-driven):

  • AIRPORTS / PIERS tag lists (text / time window / fade out) — anchor coordinates from flight_data.json;
  • FONT_PATH (CJK font, adjust per machine);
  • Vehicle sprites compose/emoji_*.png (new vehicle types use sprite_prep.py from raw_sprites/ to generate).

QC must be all green before encoding: stop/wait anchor projection 0.00px, emoji all frames within bounds (±80px), seam esp kf difference = 0, QC window written based on empirical rt segments from data (not design duration). Apparent speed budget: center translation ≤1.2 screen/s, vehicle ≤0.8 screen/s.

6. Encoding and Delivery

/home/admin/.local/bin/ffmpeg -framerate 30 -i comp_frames/f%05d.jpg \
  -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p -fps_mode passthrough \
  -movflags +faststart <route>_trip_v17.mp4
scp <route>_trip_v17.mp4 nas:/share/Public/earth/
md5sum <route>_trip_v17.mp4 && ssh nas md5sum /share/Public/earth/<route>_trip_v17.mp4   # both ends match = delivery complete

Version strategy: NAS keeps historically passed versions, deletes rejected/replaced versions; single logo version delivered (no _logo suffix dual versions).


7. Tavily Quick Search Reference (local already authenticated)

tvly at /home/admin/.local/bin/tvly (already tvly login). JSON output suitable for LLM consumption:

tvly search "HKG CEB flight route waypoints FL350" --max-results 8 --include-answer basic
tvly search "Cebu to Siquijor OceanJet ferry schedule pier" --max-results 5 -o ferry.json
tvly extract 'https://www.flightradar24.com/...'           # Full text extraction
tvly map 'earth.google.com' --limit 20                     # URL discovery
tvly research "Hong Kong Airport 07L runway SID departure route"              # Deep research (multi-turn, good for route verification)

More usage in ~/.claude/skills/tavily-* skill series.

8. Pitfall Quick Reference

PitfallWorkaround
OSRM endpoints not at anchor_load_forced pinning (insert if >25m / replace otherwise)
esp import silent failureManually dispatch change event (siq_import.mjs has it built-in)
Synthetic mouse click failsDOM el.click() (render_submit.mjs)
Job name injection not taking effectSubmit and poll/download with esp default name
Queue shows no job right after submitAPI delays a few seconds, poll before judging
Viewport resets to 985pxRun node $T/cdp/nav_es.mjs after each import/refresh
Altitude display >350km reads lowPanel display bug, rely on render
numpy does not existUse PIL ImageChops/histogram
Timeline jitter/flickerPer-frame kf + log space zoom + H zoom camera motion + mad_check.py
Read tool can't view rendered framesCrop→resize→ASCII microscope ( .:-=+*#%@) manual check
Account botguard interceptionCharacter-by-character dispatchKeyEvent + mouse interpolation (login2.mjs)
CredentialsAlways via argv/environment variables, never written into repo

相关技能