Estimate the distance to an explosion from video and audio analysis
Project description
Explosion Distance Estimator
Install this package with:
pip install explosion_distance_estimator
Then run:
explosion-distance-estimator --help
Overview
The Explosion Distance Estimator is a Python tool that estimates the distance to an explosion in a video. It calculates the distance based on the delay between the visible flash and the sound of the blast, using video and audio analysis, real-world temperature data from Open-Meteo, and basic physics principles.
Features:
- Video Analysis: Extracts frames from the video to detect the moment of the explosion (flash).
- Audio Analysis: Extracts the audio and detects the peak of the explosion's sound.
- Temperature Data: Fetches temperature data from Open-Meteo for the given date and location.
- Distance Calculation: Uses basic physics to estimate the distance to the explosion:
v = 331 + 0.6 × T distance = (sound_time - flash_time) × v
Basic run
explosion_distance_estimator
Uses:
- Default video:
test_explosion.mp4 - Today’s date
- Kyiv coordinates (lat: 50.4501, lon: 30.5234)
Full CLI options
explosion_distance_estimator --video explosion.mp4 --lat 47.0951 --lon 37.5496 --temp 1 --plot --keep --outdir output
Options:
| Flag | Description |
|---|---|
--video |
Path to the video file (MP4 with audio) |
--temp |
Weather date: either a day offset (0 = today, 1 = yesterday) or exact date (2024-03-27) |
--lat |
Latitude of the explosion location |
--lon |
Longitude of the explosion location |
--plot |
Generate 3 plots: brightness, audio spectrogram, and combined view |
--keep |
Keep extracted frames and audio after analysis |
--outdir |
Output folder for logs, plots, and CSV (default: output) |
Output
- Plots:
brightness_plot.png,audio_spectrogram.png,combined_plot.png(if--plotis set) - Run log:
output/run_YYYYMMDD_HHMMSS.log - CSV log:
output/log.csv - Temporary frames and audio (only if
--keepis used)
Example Scenarios
# Detect explosion from a video recorded yesterday in Mariupol
explosion_distance_estimator --video mariupol_blast.mp4 --temp 1 --lat 47.0951 --lon 37.5496 --plot
# Estimate using a historical date and keep all intermediate files
explosion_distance_estimator --temp 26.03.2025 --keep
How It Works
- Extract frames from the video and analyze brightness
- Detect the flash moment (spike in brightness)
- Extract audio and detect the sound peak (blast)
- Fetch temperature for the provided date/location via Open-Meteo
- Estimate the distance using basic physics:
v = 331 + 0.6 × T distance = (sound_time - flash_time) × v
Requirements
🔧 FFmpeg Required
This tool uses ffmpeg under the hood to extract audio from video files. You must have the FFmpeg binary installed and accessible in your system’s PATH.
🛠️ How to install FFmpeg:
macOS
-
With Homebrew (recommended):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install ffmpeg
-
Manual download:
- Download from: https://evermeet.cx/ffmpeg/
- Move the downloaded
ffmpegbinary to/usr/local/bin/:sudo mv ~/Downloads/ffmpeg /usr/local/bin/ chmod +x /usr/local/bin/ffmpeg
Windows
- Download FFmpeg from: https://ffmpeg.org/download.html
- Extract and move the
bin/directory to a known location (e.g.,C:\ffmpeg\bin) - Add that location to your system PATH:
- Open Start Menu → search “Environment Variables”
- Edit
PATHand addC:\ffmpeg\bin
Linux (Debian/Ubuntu)
sudo apt update
sudo apt install ffmpeg
Check installation
After installing, confirm ffmpeg is available:
ffmpeg -version
Credits
- The core logic for estimating the distance between flash and sound is based on an approach shared by @Dmojavensis. Follow him, please. He has done some incredible geolocations.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file explosion_distance_estimator-1.0.3.tar.gz.
File metadata
- Download URL: explosion_distance_estimator-1.0.3.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98ab774a02848028ed145736a2ecc946d62b20e3d154e6fe4243abbac1d0a11a
|
|
| MD5 |
58e62e36a4b8f09beca222c4f81d4389
|
|
| BLAKE2b-256 |
642a8522d2ed622f47d13d60454344ddb9d325410b996f9c872bc45f8f006cf8
|
File details
Details for the file explosion_distance_estimator-1.0.3-py3-none-any.whl.
File metadata
- Download URL: explosion_distance_estimator-1.0.3-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1838cf356b1c8c45e9cd814e74298a64baf774bb6be7a079db31d39459e9193
|
|
| MD5 |
29543e1c69d902e4eacda1cd2879ed8a
|
|
| BLAKE2b-256 |
052203f3f9c9bfedd5de9d9a78a0cc9ab6c1a433e1e8cda730119682f5ffafd6
|