Terrain Route Video

TotalClaw 作者 jack4world v0.2.0

从停靠点(城市/POI)列表生成极简地形风格的动画驾驶路线视频(MP4),无需 Remotion。使用 OSRM 进行道路跟踪几何图形,使用 OpenTopoMap 地形图块进行底图,使用 Matplotlib 进行帧渲染,使用 FFmpeg 进行编码。当用户要求创建/导出动态自动驾驶路线图视频(飞行跟随相机、路线绘制动画、标签)并希望其沿着道路/高速公路行驶时使用。

源码 ↗

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:jack4world~jack4world-terrain-route-video
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Ajack4world~jack4world-terrain-route-video/file -o jack4world-terrain-route-video.md
Git 仓库获取源码
git clone https://github.com/openclaw/skills/commit/228741d7c9f1de786226bd03aa6311f30df0c00e
# Terrain Route Video (no Remotion)

## Output defaults (recommended)

- Size: `1600x900`
- FPS: `30`
- Duration: `12s`
- Style: dark terrain basemap + red route line + cyan head dot

## Inputs

### Option A) Road-follow (OSRM) via `stops.json`

Create a `stops.json` file:

```json
{
  "stops": [
    {"id": "01", "name": "襄阳", "lon": 112.1163785, "lat": 32.0109980},
    {"id": "02", "name": "老河口", "lon": 111.7575073, "lat": 32.4370526}
  ]
}
```

Schema reference: `references/stops.schema.json`.

### Option B) Track-follow via `.gpx` / `.kml`

If you already have a route track (GPX/KML), you can generate the video **directly from the track geometry** (no OSRM calls):

- GPX: uses `<trkpt>` (track points) or falls back to `<rtept>`
- KML: supports both:
  - standard `<LineString><coordinates>`
  - 2bulu/Google-style `<gx:Track><gx:coord>` (common in hiking app exports)

## Runbook

1) Create a fresh working folder (keeps caches + frames local).

2) Create a Python venv and install deps:

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install numpy matplotlib pillow requests
```

3) Render video (choose one):

**OSRM road-follow mode (`stops.json`)**
```bash
python /path/to/skills/terrain-route-video/scripts/terrain_route_video.py \
  --stops stops.json \
  --out out.mp4 \
  --size 1600x900 \
  --fps 30 --duration 12 \
  --title "江汉平原到洞庭湖 · 足迹" \
  --subtitle "襄阳 → 老河口 → 荆州 → 监利 → 洪湖·峰口镇 → 岳阳"
```

**GPX/KML track mode**
```bash
python /path/to/skills/terrain-route-video/scripts/terrain_route_video.py \
  --route my-track.gpx \
  --out out.mp4 \
  --size 1600x900 \
  --fps 30 --duration 12 \
  --title "My Trip" \
  --subtitle "GPX/KML track"
```

Notes:
- The script creates `frames/` and `.tile-cache/` in the current folder.
- If the user complains the line is not “hugging highways”, keep **full OSRM geometry** (default) and avoid any simplification.
- If text shows missing glyphs, pass `--font /System/Library/Fonts/Hiragino Sans GB.ttc` (default) or another CJK font path.
- OpenTopoMap tile availability can vary by zoom/region/network. The script will auto-fallback to a lower zoom if tile requests fail.

## Useful tuning flags

### Camera / route

- `--zoom 18` (terrain tile zoom; default is 18; may auto-fallback if tiles fail)
- `--lookahead 0.02` (camera looks ahead on the route; smaller = steadier)
- `--dwell 0` (pause frames at each stop; default 0)
- `--no-follow` (static full-route view, no fly-follow)

### Basemap readability (new)

These are useful when map labels feel too dark/washed out.

- `--basemap-alpha 0.85` (make basemap more visible)
- `--overlay-alpha 0.25` (reduce the dark overlay; clearer labels)
- `--basemap-contrast 1.20` (increase contrast)
- `--basemap-sharpness 1.45` (sharpen text/lines)
- `--basemap-color 0.80` (saturation multiplier)