trueflac
Tells whether a FLAC file was made from an MP3, an AAC, an Opus or a Vorbis file.
Why • Install • Command line • Python • How it works • Results • References • Documentation
👋 Why trueflac?
A FLAC file promises the sound of the CD. Converting an MP3 to FLAC keeps that promise on the label only: the file is bigger, the sound is the MP3's. Music shared online, old downloads and "lossless" packs often hold such files, and nothing in their tags says so.
trueflac looks at the sound itself and answers suspect or ok for each file. It never says "fake": an old recording or a filtered master can look like a lossy file. When in doubt it keeps quiet, so a genuine file is never accused on its word: on its bench, no genuine file is flagged.
It is the engine of the fake FLAC check in S.O.K, and works on its own as a command and a Python library.
✨ Features
- Two independent clues. The highs cut like an encoder does, or the block grid of the encoder still in the sound. The second one catches what the first cannot see: MP3 V0 and 320 kbit/s, AAC 256, Vorbis.
- Names the codec when it finds its grid: MP3, AAC or Vorbis.
- FLAC, WAV and AIFF, 16 or 24 bits, 44.1 to 96 kHz, mono or stereo.
- Read only. It never writes, moves or deletes a file, and never goes on the network.
- Light. numpy and soundfile, nothing else. About 1.5 s for a genuine track on an Apple Silicon Mac, half that on four threads.
- Made for applications. Verdicts are data that an app words in its own language, analyses can be canceled, and it is safe to run on several threads.
📥 Install
pip install trueflac
Or as a command only, with uv: uv tool install trueflac.
Python 3.11 or later. soundfile ships its own libsndfile on Linux, macOS and Windows.
💻 Command line
$ trueflac check Album/
ok 01 - Echoplex (CD).flac No sign of a lossy source
suspect 02 - Echoplex (from MP3 128).flac Highs cut at 16.6 kHz, like a lossy file
suspect 03 - Echoplex (from MP3 V0).flac Block grid of a lossy encoder (MP3)
suspect 04 - Echoplex (from AAC 256).flac Block grid of a lossy encoder (AAC)
suspect 05 - Echoplex (from Vorbis q6).flac Block grid of a lossy encoder (Vorbis)
This is a real run on one clip of the bench (Nine Inch Nails, The Slip) and four fakes made from it. Only the MP3 128 lost its highs; the three others keep them and are seen through their grid.
trueflac check <file or folder>... [--json]
trueflac --version
Folders are searched for .flac, .wav, .aiff and .aif files. --json prints one JSON object
per file:
$ trueflac check --json "Album/02 - Echoplex (from MP3 128).flac"
{"path": "Album/02 - Echoplex (from MP3 128).flac", "status": "suspect", "clue": "cut", "codec": null, "cutoff_hz": 16618.24951171875, "grid_contrast": null, "sample_rate": 44100, "bit_depth": 16, "channels": 2, "seconds": 60.0, "error": null}
The exit code is 1 when a file is suspect, 0 otherwise.
🐍 Python
from trueflac import Clue, Status, analyze
verdict = analyze("02 - Single.flac")
if verdict.status is Status.SUSPECT:
if verdict.clue is Clue.CUT:
print(f"highs cut at {verdict.cutoff_hz:.0f} Hz")
else: # Clue.GRID
print(f"made from {verdict.codec}") # "MP3", "AAC" or "Vorbis"
A Verdict holds data, not sentences, so an application can word it in its own language:
| Field | Meaning |
|---|---|
status |
Status.OK, Status.SUSPECT or Status.UNREADABLE |
clue |
why it is suspect: Clue.CUT (the highs stop like after an encoder) or Clue.GRID (the encoder's block grid is still there) |
codec |
"MP3", "AAC" or "Vorbis", for a grid |
cutoff_hz |
where the highs end, when they end sharply |
grid_contrast |
strength of the best block grid (suspect from 10) |
sample_rate, bit_depth, channels, seconds |
the file |
error |
why the file could not be read |
describe(verdict) gives the English line the command line prints.
analyze() never prints, never raises on a broken file (the verdict is unreadable) and is safe
to call from several threads. It takes an optional cancel callable, checked between its stages;
when it returns True, analyze() raises Cancelled:
import threading
from trueflac import Cancelled, analyze
stop = threading.Event()
try:
verdict = analyze(path, cancel=stop.is_set)
except Cancelled:
...
🔬 How it works
1. Cut highs. trueflac averages the spectrum at eight points of the track. An encoder throws away the highs it finds inaudible: above its low-pass, a decoded file holds nothing but the rounding noise of its bit depth, while a recording, even a 78 rpm disc or a quiet piano, keeps a little noise of its own. A sharp fall to that floor below 20.3 kHz is suspect.
2. Codec grid, when the highs tell nothing. An encoder cuts the sound into blocks, moves each block to frequencies with a fixed transform and sets to zero what it finds inaudible. Analyzed with the same transform, at the same block start, the decoded file shows those zeros again. A recording has no preferred start: every start looks the same. This idea comes from the "inverse decoder" of Herre and Schug and from the detectors of Derrien and his co-authors (see References).
trueflac tries every start:
- MP3: its 576 lines per granule are rebuilt from the standard (polyphase filter bank, 18-point MDCT, alias butterflies) and checked against the minimp3 decoder.
- AAC and Vorbis: a 2048-point MDCT with the windows their encoders use (sine and Kaiser-Bessel derived for AAC, the Vorbis power window).
A grid counts only when it stands far above all other starts (a contrast of 10, where genuine tracks stay under 6) and when two separate parts of the track agree on where it starts.
📊 Results
On a bench of 22 genuine clips (rock, solo piano, 78 rpm transfers) and the same clips encoded and decoded back, with flac-detective 2.6.1 run on the same files for reference:
| Files flagged (out of 22) | trueflac | flac-detective |
|---|---|---|
| Genuine (false accusations) | 0 | 0 |
| MP3 128 / 192 / 256 / 320 kbit/s | 22 / 22 / 21 / 21 | 4 / 5 / 0 / 0 |
| MP3 V0 | 22 | 0 |
| AAC 256 (ffmpeg / Apple) | 19 / 18 | 12 / 0 |
| Opus 192 | 17 | 12 |
| Vorbis q6 | 22 | 21 |
| Time per file | 0.9 s | 2.7 s |
Also measured, with no genuine file flagged: decodes with dither or to 24 bits, genuine clips with dither, 48 and 96 kHz, mono, 3-second clips, WAV and AIFF. Times are on an Apple Silicon Mac (average over the bench; a genuine track takes the longest, about 1.5 s, since every test runs).
Known limits
- Opus is only seen through its cut: it works at 48 kHz, and the resampling back to 44.1 kHz blurs its grid.
- Noise-shaped dither fills the highs and can hide an AAC (Apple AAC: 11 of 22).
- Very quiet highs (solo piano) leave little to measure.
- Lossy at the source: a phone recording or a master made from MP3 is reported suspect, and rightly so, even when the shop sells it as lossless.
- A bench of 22 clips is small. Report a wrong verdict: it is how the bench grows.
📖 Documentation
The full guide, how the detection works in detail, every result, the sources and the Python API reference are on opalehq.github.io/trueflac.
🧪 Bench
bench/ rebuilds every clip above from recordings freely available on the
Internet Archive and scores trueflac on them. No audio is committed.
🧑💻 For developers
uv sync
uv run pytest
uv run ruff check src tests bench scripts
uv run mypy src
uv installs Python 3.13 and the development tools from uv.lock.
Rules, the bench and commit conventions are in CONTRIBUTING.md.
🛠️ Roadmap
- More genuine music in the bench, from more styles and eras.
- Opus through its own grid, before resampling.
- Fake high resolution: a CD file blown up to 96 kHz or 24 bits.
📚 References
Detection of lossy coding in decoded audio:
- J. Herre, M. Schug, Analysis of Decompressed Audio: The "Inverse Decoder", AES 109th Convention, paper 5256, 2000. AES E-Library
- S. Moehrs, J. Herre, R. Geiger, Analysing Decompressed Audio with the "Inverse Decoder": Towards an Operative Algorithm, AES 112th Convention, paper 5576, 2002. AES E-Library
- J. Lacroix, Y. Prime, A. Remy, O. Derrien, Lossless Audio Checker: A Software for the Detection of Upscaling, Upsampling, and Transcoding in Lossless Musical Tracks, AES 139th Convention, 2015. AES E-Library
- O. Derrien, Detection of Genuine Lossless Audio Files: Application to the MPEG-AAC Codec, Journal of the Audio Engineering Society, vol. 67, no. 3, pp. 116–123, 2019. AES E-Library
trueflac follows the idea of these papers (look for the coder's transform grid in the decoded sound); its code is written from the codec specifications below, not from theirs.
Codecs:
- ISO/IEC 11172-3:1993, Coding of moving pictures and associated audio, Part 3: Audio (MPEG-1 Layer III). The synthesis window was read back from minimp3 (CC0), and the line shapes checked against it.
- ISO/IEC 13818-7, Advanced Audio Coding (AAC): sine and Kaiser-Bessel derived windows. The ffmpeg AAC encoder uses the KBD window with alpha 4 for long blocks (libavcodec/aactab.c).
- Xiph.Org, Vorbis I specification, section 4.3.1: the window slope y = sin(π/2 · sin²((x + 0.5)/n · π)).
Tools:
- flac-detective, the reference in the results above.
- libsndfile through soundfile, to read the files.
🤝 Contribution
Issues and pull requests are welcome: see CONTRIBUTING.md. A wrong verdict is the most useful report. Security problems go through SECURITY.md.
📄 License
Metadata
Release files for trueflac 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trueflac-0.1.0.tar.gz | 21.8 kB | With provenance | Details for trueflac-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trueflac-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for trueflac-0.1.0-py3-none-any.whl |
Total release size: 43.5 kB
Release files / trueflac-0.1.0.tar.gz
| Download URL | trueflac-0.1.0.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fc81dad145739d09293aacd02700155ee3534fe257f8d79599d79b3aa03f950
|
|
BLAKE2b-256 checksum How to use checksums |
ffa4aa0d889ee96e95d7244fed407bb279565fc275c1eb93198c7908aa2aafe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / trueflac-0.1.0-py3-none-any.whl
| Download URL | trueflac-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6fd71334cc28fe4a1643d6365b89e79c7170bd32831cf3795d982c1465258885
|
|
BLAKE2b-256 checksum How to use checksums |
b3f2f133498d62a067b100c8b9e829122d7c326984033cd28db928e5363e543a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for trueflac 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for trueflac-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.