r/DSP • • 29d ago

I made a small open-source tool that dates audio recordings from their mains hum (ENF)

I made a small open-source tool that estimates when an audio recording was made from the mains hum in it (electric network frequency analysis): https://github.com/tijszwinkels/enf-timestamp

Video with the full story: https://youtu.be/bi7EwMiDQTQ

How it works: band-pass around a hum harmonic, track the peak once per second (16 s Hann window, zero-padded FFT, quadratic interpolation), then a sliding Pearson correlation against a 1-second grid-frequency log, done with FFT convolution so days of reference data take seconds. It includes a logger for Continental-European grid data (Gridradar's free API) and a strict confidence verdict.

This has been written with a coding agent.

What I found: 10 minutes of laptop audio, matched against 36 h of grid data, landed 6 s from the true start (100 Hz line, z ≈ 5). A phone on its charger (50 Hz electrical pickup) got the right minute, with a weak margin. Phones on battery and a quiet room gave nothing usable.

22 Upvotes

3 comments sorted by

7

u/TenorClefCyclist 29d ago

I first learned about this technique at an AES Forensic Audio conference held in Denver in 2008. It's cool that you made an open-source tool to do it.

1

u/fb39ca4 29d ago

Would deriving your camera's frame rate/pixel clock from mains frequency combat this?

0

u/[deleted] 28d ago

[deleted]

1

u/Tumblecow 27d ago

If you're talking about the "Sound that leaks your location" video (https://www.youtube.com/watch?v=UytYrhYLOKI) - Yes! - You're totally right! That heavily inspired this video.

At first when it appeared in my feed I actually didn't watch it, because I thought it would be the mains hum technique.

Ofc. Colsto's work is much more impressive. It combines a handful of layers, and it's actually a new approach where I'm just retelling something that has been known for years.