Skip to content

Instantly share code, notes, and snippets.

@windytan
Last active August 29, 2023 08:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windytan/e2ebb8ed872f89b1ec6a31dd033c7168 to your computer and use it in GitHub Desktop.
Save windytan/e2ebb8ed872f89b1ec6a31dd033c7168 to your computer and use it in GitHub Desktop.
Decode the helicopter position signal from youtube videos!
#!/bin/sh
# Decode the helicopter position signal from youtube videos!
# It makes a KML file. You can open it in Google Earth or many other GIS programs.
# Requires sox, perl, and minimodem, and optionally youtube-dl / ffmpeg
# https://www.windytan.com/2014/02/mystery-signal-from-helicopter.html
# !!!
# !!! Don't just run any random script you find online! Read what it does first!
# !!!
# Download the audio track (uncomment if you don't have the audio yet)
# youtube-dl --extract-audio --audio=format wav ....
# Or if you have just a video file:
# ffmpeg -i video-file.mp4 helicopter-audio.wav
# Extract the right channel (if the signal is on left, change the 2 to 1)
# Replace file names with yours
sox helicopter-audio.wav helicopter-audio-mono.wav remix 2 sinc 500-5000
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<kml xmlns="http://www.opengis.net/kml/2.2">'
echo '<Document>'
# Make tr accept non-ascii bytes
export LC_CTYPE=C
# Decode FSK to coordinates
minimodem --rx 1200 -f helicopter-audio-mono.wav 2>/dev/null | \
tr '\200-\377\r' '\000-\177\n' | \
perl -ne 'if (/^#L (N|S)(..)(....) (W|E)(...)(....)/) {
print("<Placemark><Point><coordinates>".
(($4 eq "E") ? 1 : -1) * ($5 + $6 / 6000).",".
(($1 eq "N") ? 1 : -1) * ($2 + $3 / 6000).",0".
"</coordinates></Point></Placemark>\n"); }'
echo '</Document>'
echo '</kml>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment