Skip to main content

Parse DJI drone SRT telemetry files and overlay flight data onto video footage

Project description

DJI Telemetry

A Python library to parse DJI drone SRT telemetry files, export flight data, and overlay telemetry onto video footage.

Tested with DJI Neo 2 but should work with other DJI drones that generate SRT telemetry files.

Features

  • Parse DJI SRT telemetry files (per-frame metadata)
  • Calculate horizontal/vertical speeds from GPS data
  • Export to CSV, JSON, or GPX formats
  • Overlay telemetry data onto video footage
  • Generate transparent overlay videos or frame sequences

Installation

pip install dji-telemetry

Or install from source:

git clone https://github.com/jetervaz/dji-telemetry.git
cd dji-telemetry
pip install -e .

Quick Start

Python Library

from dji_telemetry import parse_srt, process_video, export

# Parse telemetry data
telemetry = parse_srt('flight.SRT')

# Show flight stats
print(f"Duration: {telemetry.duration_seconds:.1f}s")
print(f"Distance: {telemetry.total_distance:.1f}m")
print(f"Max altitude: {telemetry.max_altitude:.1f}m")
print(f"Max speed: {telemetry.max_speed * 3.6:.1f} km/h")

# Export to different formats
export(telemetry, 'flight.csv')
export(telemetry, 'flight.json')
export(telemetry, 'flight.gpx')

# Process video with overlay
process_video('flight.MP4', telemetry, 'flight_with_telemetry.mp4')

Command Line

# Process video with telemetry overlay
dji-telemetry overlay video.MP4 --audio

# Generate transparent overlay video (for compositing)
dji-telemetry overlay-only video.SRT -o overlay.mp4 --width 3840 --height 2160

# Generate PNG frame sequence (for video editors)
dji-telemetry frames video.SRT -o frames/ --width 1920 --height 1080

# Export telemetry data
dji-telemetry export video.SRT -o telemetry.csv
dji-telemetry export video.SRT -o telemetry.json
dji-telemetry export video.SRT -o flight.gpx

# Show file information
dji-telemetry info video.SRT
dji-telemetry info video.MP4

API Reference

Parsing

from dji_telemetry import parse_srt, TelemetryData, TelemetryFrame

# Parse SRT file
telemetry: TelemetryData = parse_srt('flight.SRT')

# Access frames
for frame in telemetry.frames:
    print(f"Alt: {frame.rel_alt}m, Speed: {frame.h_speed * 3.6:.1f} km/h")

# Get frame at specific time
frame = telemetry.get_frame_at_time(5000)  # 5 seconds

# Flight statistics
telemetry.duration_seconds
telemetry.total_distance
telemetry.max_altitude
telemetry.max_speed
telemetry.start_coordinates
telemetry.end_coordinates

Exporting

from dji_telemetry import parse_srt, export, to_csv, to_json, to_gpx

telemetry = parse_srt('flight.SRT')

# Auto-detect format from extension
export(telemetry, 'data.csv')
export(telemetry, 'data.json')
export(telemetry, 'track.gpx')

# Or use specific exporters
to_csv(telemetry, 'data.csv', include_all_fields=True)
to_json(telemetry, 'data.json', indent=2)
to_gpx(telemetry, 'track.gpx', name='My Flight')

Video Processing

from dji_telemetry import (
    parse_srt,
    process_video,
    generate_overlay_video,
    generate_overlay_frames,
    add_audio,
    OverlayConfig
)

telemetry = parse_srt('flight.SRT')

# Custom overlay configuration
config = OverlayConfig(
    show_altitude=True,
    show_speed=True,
    show_vertical_speed=True,
    show_coordinates=True,
    show_camera_settings=True,
    show_timestamp=True,
    show_speed_gauge=True,
    gauge_max_speed_kmh=60.0,
)

# Process video with overlay
process_video(
    'flight.MP4',
    telemetry,
    'output.mp4',
    config=config,
    progress_callback=lambda cur, total: print(f"{cur}/{total}")
)

# Add audio from original
add_audio('output.mp4', 'flight.MP4', 'output_with_audio.mp4')

# Generate overlay-only video (black background, for compositing)
generate_overlay_video(
    telemetry,
    'overlay.mp4',
    width=3840,
    height=2160,
    fps=30.0,
    config=config
)

# Generate PNG frame sequence (with transparency)
generate_overlay_frames(
    telemetry,
    'frames/',
    width=1920,
    height=1080,
    fps=30.0,
    format='png'
)

Overlay Configuration

from dji_telemetry import OverlayConfig

config = OverlayConfig(
    # Toggle elements
    show_altitude=True,
    show_speed=True,
    show_vertical_speed=True,
    show_coordinates=True,
    show_camera_settings=True,
    show_timestamp=True,
    show_speed_gauge=True,

    # Speed gauge
    gauge_max_speed_kmh=50.0,

    # Styling
    font_scale_factor=1.0,
    text_color=(255, 255, 255),      # BGR: White
    shadow_color=(30, 30, 30),       # BGR: Dark gray
    gauge_color=(255, 255, 255),     # BGR: White
    gauge_needle_color=(255, 200, 0), # BGR: Orange
)

Overlay Layout

The default overlay displays:

┌─────────────────────────────────────────────────────────────┐
│ ALT: 57.2m                                        ISO 100   │
│ H.SPD: 12.5 km/h                                1/1250.0s   │
│ V.SPD: +1.2 m/s                                     f/2.2   │
│                                                   EV -1.3   │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│                          ┌───┐                              │
│                          │ 12│                              │
│                          │kmh│                              │
│                          └───┘                              │
│ 29.685883S  53.777843W                           09:58:21   │
└─────────────────────────────────────────────────────────────┘

DJI SRT Format

DJI drones generate SRT files with per-frame telemetry:

1
00:00:00,000 --> 00:00:00,033
<font size="28">FrameCnt: 1, DiffTime: 33ms
2026-01-30 09:58:21.637
[iso: 100] [shutter: 1/1250.0] [fnum: 2.2] [ev: -1.3] [ct: 6700]
[latitude: -29.685883] [longitude: -53.777843]
[rel_alt: 57.200 abs_alt: 204.644] ...</font>

Supported Fields

Field Description
iso ISO sensitivity
shutter Shutter speed
fnum Aperture (f-number)
ev Exposure compensation
ct Color temperature (Kelvin)
latitude GPS latitude
longitude GPS longitude
rel_alt Relative altitude (from takeoff)
abs_alt Absolute altitude (sea level)

Calculated Fields

Field Description
h_speed Horizontal speed (calculated from GPS)
v_speed Vertical speed (calculated from altitude)
distance Cumulative distance traveled

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dji_telemetry-1.0.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dji_telemetry-1.0.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file dji_telemetry-1.0.1.tar.gz.

File metadata

  • Download URL: dji_telemetry-1.0.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dji_telemetry-1.0.1.tar.gz
Algorithm Hash digest
SHA256 265250c681931631d5b89d5ec5f3dac9a06b2494d6218d8805f654b256a3ad9f
MD5 b1ac94022bcf8910b43878fe3396969c
BLAKE2b-256 a14252c6cca6fe6496541984d6f831d79f7ecca76e7b1fad153cf37bc94f020b

See more details on using hashes here.

File details

Details for the file dji_telemetry-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: dji_telemetry-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for dji_telemetry-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7a2efe96e173044a52238efbf48bc3a30f692e1b698c25eb0b7aada5e638d7a
MD5 51672d84ab072c807fbc3d50ad711e43
BLAKE2b-256 6719ae4b0b9be14c1d572d714402b46210d2081dba08068ac7f23541c1cb00d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page