This Python script generates a video from a flight path by downloading satellite images from Mapbox API and stitching them together into a video using FFmpeg.
- Python 3
- requests
- numpy
- FFmpeg
You will also need a Mapbox API key. If you don't have one, you can create a free account on their website to obtain it. Put it in the file mapboxkey
python fullflight.py start_airport end_end duration fps orientation
- start_location: The starting airport code (e.g., JFK).
- end_location: The ending airport code (e.g., LAX).
- duration: The length of the video in seconds.
- fps: The frames per second of the video.
- orientation: The orientation of the camera, either 'l' for left or 'r' for right.
The script generates a video file named flight.mp4 from satellite images stitched together.
import windowseat
# Retrieve coordinates for airport
start, end = windowseat.get_db("JFK","LAX") # returns lon, lat to please Mapbox api
# calculate flight path
frames = 30 * 15 # fps * seconds
path = windowseat.get_points_on_line(start, end, frames)
# calculate initial bearing
heading = windowseat.get_angle_between_coordinates(start,end)
heading += 90 # for right window, or -= 90 for left
zoom = 11 # google maps standard heading between 1 and 22
for i, v in enumerate(path):
windowseat.get_photo(v, zoom, "MAPBOX_API_KEY",heading,f"photos/{i:04n}")
# use ffmpeg to stitch together
SLC -> AUS
This script uses the Global Airport Database by Arash Partow to obtain the latitude and longitude of the airports and airnav.com for runway headings.