# How Google Timeline Visualizer Compresses Long Trips in Videos

> Discover how Google Timeline Visualizer compresses long trips in videos using configurable exponents to enhance visual engagement while preserving trip geometry. Learn more!

- Repository: [mahlernim/google-timeline-visualizer](https://github.com/mahlernim/google-timeline-visualizer)
- Tags: internals
- Published: 2026-08-23

---

**Google Timeline Visualizer reduces the visual impact of unusually long "transfer" segments like flights and long drives by applying a configurable exponent to raw segment distances, preserving total trip geometry while making video playback more visually engaging.**

The open-source tool `mahlernim/google-timeline-visualizer` implements a sophisticated *long-trip timing compression* algorithm that solves the common visualization problem where long transit segments dominate video timelines. This technique ensures that brief, interesting segments remain visible while major transfers don't monopolize screen time.

## Understanding Long-Trip Compression in Google Timeline Visualizer

When visualizing GPS trajectories, raw distance-based timelines often suffer from visual imbalance. A two-hour flight might consume significantly more video time than a full day of local exploration. According to the source code in [`visualizer.py`](https://github.com/mahlernim/google-timeline-visualizer/blob/main/visualizer.py), the application addresses this by replacing linear distance mapping with an exponential transformation that selectively slows the growth of long segments.

## Compression Presets and Configuration

The compression behavior is controlled through user-friendly presets defined in [`visualizer.py`](https://github.com/mahlernim/google-timeline-visualizer/blob/main/visualizer.py) at lines 95-101. Each preset maps to a specific exponent value that determines the compression strength:

```python
COMPRESSION_PRESETS = {
    'off': 1.00,      # No compression applied

    'gentle': 0.92,   # Minimal compression

    'balanced': 0.85, # Default setting

    'strong': 0.75,   # Aggressive compression

    'stronger': 0.65  # Maximum compression

}

```

### Available Preset Values

- **Off** (`1.00`): Raw distances are used without modification, resulting in a linear mapping between video progress and geographic distance.
- **Gentle** (`0.92`): Slight reduction of long segments while maintaining relatively accurate timing proportions.
- **Balanced** (`0.85`): The default preset that provides moderate compression suitable for mixed urban and transit itineraries.
- **Strong** (`0.75`): Significant compression of lengthy transfers, ideal for road trips with extensive highway segments.
- **Stronger** (`0.65`): Maximum compression designed for international travel with lengthy flights.

## The Mathematics of Distance Compression

The core algorithm, implemented in [`visualizer.py`](https://github.com/mahlernim/google-timeline-visualizer/blob/main/visualizer.py) between lines 26-38, calculates **effective distance** by raising each segment's raw distance to the selected exponent:

```python

# Pseudo-code based on visualizer.py implementation

effective_distance = raw_segment_distance ** exponent
effective_total += effective_distance

```

This mathematical approach ensures that:
- Long segments grow slower than short ones because values between 0 and 1 decrease when raised to fractional powers
- The **effective total distance** (`effective_total`) replaces the linear cumulative distance when mapping video frames to geographic positions
- Short, local movements retain their relative visual weight while major transfers are temporally compressed

For example, a 1000 km flight segment processed with the default `balanced` exponent of 0.85 yields an effective distance of `1000 ** 0.85 ≈ 501 km`, effectively halving its screen time contribution compared to linear mapping.

## Implementation Details in visualizer.py

The compression system operates during the video generation phase without altering the underlying route geometry. As implemented in `mahlernim/google-timeline-visualizer`, the `effective_total` value serves as the timeline index for frame rendering, while the actual GPS coordinates remain untouched to preserve geographic accuracy.

This implementation choice means that while the video playback speed varies across different trip segments—accelerating during long transfers and decelerating during local exploration—the spatial path displayed on screen remains faithful to the original Timeline data.

## Summary

- **Long-trip timing compression** in Google Timeline Visualizer uses exponential distance scaling to reduce the visual dominance of extended transit segments.
- Five presets ranging from `off` (1.00) to `stronger` (0.65) allow users to configure compression strength, with `balanced` (0.85) as the default.
- The algorithm calculates `effective_total` by summing `segment ** exponent` values, as defined in [`visualizer.py`](https://github.com/mahlernim/google-timeline-visualizer/blob/main/visualizer.py) lines 26-38.
- Compression affects only the temporal mapping of video frames, not the actual route geometry or GPS coordinates.
- Long segments experience greater temporal reduction than short segments due to the mathematical properties of fractional exponents.

## Frequently Asked Questions

### What is long-trip timing compression?

Long-trip timing compression is a video generation technique used by Google Timeline Visualizer to reduce the amount of screen time allocated to lengthy transit segments like flights or highway drives. It applies a fractional exponent to raw segment distances, causing longer distances to contribute disproportionately less to the video timeline while preserving the actual geographic route.

### How does the compression affect video playback speed?

Video playback speed becomes variable rather than constant. During compressed segments (long flights or drives), the video advances faster through geographic space, while brief local activities play at relatively slower speeds. This creates a visually balanced narrative where both major transfers and detailed exploration receive appropriate screen time without altering the actual path shown on screen.

### Which compression preset should I use for international flights?

For international flights mixed with local exploration, the `balanced` preset (0.85 exponent) works best as the default, though `strong` (0.75) is recommended when flights dominate the itinerary. The `stronger` setting (0.65) suits round-the-world trips with numerous long-haul segments, preventing any single flight from monopolizing the visualization timeline.

### Does compression alter the actual route geometry?

No, compression only affects the temporal mapping between video progress and geographic position. The `effective_total` calculation in [`visualizer.py`](https://github.com/mahlernim/google-timeline-visualizer/blob/main/visualizer.py) modifies which GPS coordinate displays at each video frame, but the underlying latitude and longitude data remains unchanged. The route shape, turn precision, and spatial relationships stay geographically accurate throughout the compressed visualization.