Last active
August 20, 2024 17:24
-
-
Save windytan/e2ebb8ed872f89b1ec6a31dd033c7168 to your computer and use it in GitHub Desktop.
Decode the helicopter position signal from youtube videos!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 yt-dlp / ffmpeg | |
# https://www.windytan.com/2014/02/mystery-signal-from-helicopter.html | |
# Remove this line | |
echo "Don't just run any random script you find online! Read what it does first!" && exit 1 | |
# Download the audio track from youtube (uncomment if you don't have the audio yet) | |
# yt-dlp --extract-audio --audio=format wav https://www.youtube.com/... | |
# 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 (input file, output file) | |
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