Skip to content

feat: GPX Import + Video Overlay + Exporter#2

Open
juakoasistente wants to merge 1 commit into
mainfrom
feature/gpx-video-overlay
Open

feat: GPX Import + Video Overlay + Exporter#2
juakoasistente wants to merge 1 commit into
mainfrom
feature/gpx-video-overlay

Conversation

@juakoasistente

Copy link
Copy Markdown
Owner

El motor correcto para Kinetic

El flujo: usuario importa vídeo + GPX → Kinetic sincroniza y renderiza overlay → exporta vídeo final

3 ficheros, 812 líneas:

Services/GPX/GPXParser.swift

  • Parsea GPX de Strava, Garmin, Wahoo, etc.
  • Extrae: coordenadas, altitud, timestamps, velocidad, HR, cadencia, potencia
  • dataAt(timeOffset:) → interpola datos a cualquier segundo del vídeo
  • Calcula: distancia total, velocidad max/media, elevación

Services/Overlay/OverlayRenderer.swift

  • Renderiza UIImage con los datos de telemetría
  • 3 estilos: modern (tarjetas dark), minimal (solo texto), racing (bold + acento rojo)
  • Configurable: posición, métricas, métrico/imperial, opacidad, escala

Services/VideoProcessor/VideoExporter.swift

  • Importa vídeo del carrete
  • Sincroniza GPX con timeline del vídeo (offset configurable)
  • Custom AVVideoCompositor quema overlay en cada frame
  • Exporta MP4 con audio
  • Presets: 720p, 1080p, original
  • Progress tracking + cancelación

Uso:

// 1. Parse GPX
let parser = GPXParser()
let track = parser.parse(url: gpxFileURL)

// 2. Configure overlay
var config = OverlayRenderer.OverlayConfig()
config.style = .racing
config.position = .bottomLeft

// 3. Export
let exporter = VideoExporter()
let exportConfig = VideoExporter.ExportConfig(
    videoURL: videoURL,
    gpxTrack: track,
    overlayConfig: config,
    timeOffset: 3.5 // GPX starts 3.5s after video
)
let outputURL = try await exporter.export(config: exportConfig)

Core engine for importing GPX + video and exporting with overlay:

GPXParser:
- Parse GPX/XML files (Strava, Garmin, etc.)
- Extract: coordinates, altitude, timestamps, speed, HR, cadence, power
- Interpolate data at any time offset (for frame-by-frame sync)
- Calculate: total distance, max/avg speed, elevation gain
- Heading calculation between points

OverlayRenderer:
- Render telemetry data as UIImage overlay
- 3 styles: modern (dark cards), minimal (text only), racing (bold + red accent)
- Configurable: position, metrics shown, metric/imperial, opacity, scale
- Renders: speed, distance, time, altitude, elevation gain

VideoExporter:
- Import video from camera roll
- Sync GPX data with video timeline (configurable time offset)
- Custom AVVideoCompositor burns overlay onto each frame
- Exports MP4 with audio preserved
- Quality presets: 720p, 1080p, original
- Progress tracking + cancellation support
- CIImage compositing for overlay blending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant