A command-line tool to detect "fake" lossless audio files and optionally plot their frequency distribution.
Go
1
39 commits
updated Sep 30, 2026
A command-line tool to detect "fake" lossless audio files and optionally plot their frequency distribution. Analysis of lossy files is also supported.
fakeflac-go estimates the percentage of the audio spectrum effectively remaining after a bad transcode from a lossy source.
Algorithm ported from mevdschee/fakeflac with some adjustments; scores may not match. This algorithm is known to produce false negatives, see Limitations.
go install github.com/drichline/fakeflac-go@v0.1.3
This will compile and install the binary to $GOPATH/bin, where $GOPATH defaults to ~/go on Linux/MacOS and %USERPROFILE%\go on Windows. You may have to add this directory to your system's PATH.
docker run --rm -v ./:/files ghcr.io/drichline/fakeflac-go:v0.1.3 [OPTIONS] [FILES]
For systems using podman:
podman run --rm -v ./:/files ghcr.io/drichline/fakeflac-go:v0.1.3 [OPTIONS] [FILES]
Ensure the command is run from inside the directory containing the audio files, or adjust the volume mount directory.
Note that the container image bundles native ffmpeg, so the -ffmpeg flag is enabled by default.
Untested prebuilt binaries for Linux x86/ARM, MacOS Intel/ARM, and Windows 10+ are provided on the releases page; use at your own risk.
Note: ffmpeg is embedded in fakeflac-go and thus not required to build or run
-ffmpeg uses the system ffmpeg for significantly improved performance, see Usage.$ fakeflac-go fake.flac real.flac
Output:
fake.flac: 73
real.flac: 100
fakeflac-go accepts a space-separated list of filenames, and will ignore unsupported (e.g. text) files. Both lossless (e.g. .flac, .alac, .wav) and lossy (e.g. .mp3) formats are supported. For each file, fakeflac-go will output a score of 0-100 to the terminal, with 100 being a "perfect flac."
The resulting numeric score represents the percentage of "real" frequencies up to 22 kHz present in the input file. Note that scores are only an estimate and may not be accurate for some edge-cases and lossy encoders, see Limitations.
-plot saves the spectrum plot of each file to the current directory, named after the input file with .png appended.
-threads sets the maximum number of active Goroutine workers. Defaults to the number of logical CPU cores present.
-ffmpeg uses the system's ffmpeg instead of embedded ffmpeg, greatly improving performance.
ffmpeg must be available in the system's $PATH-boxcardx, -diff, -dx, and -limit: see Tuning
Usage: fakeflac-go [OPTIONS] [FILES]
Options:
-plot
Enable spectrum plot output
-threads int
Limit number of concurrent processes
-ffmpeg
Use system-installed ffmpeg if available
-boxcardx int
Number of boxcar filter spectrum bins (default 500)
-diff float
Lowpass cutoff magnitude drop test limit (default 1.25)
-dx int
Lowpass cutoff test window size in Hz (default 441)
-limit float
Lowpass cutoff magnitude ratio test limit (default 1.1)
All input files are resampled to a 44.1 kHz 16 bit PCM stream by ffmpeg, so that the frequency range is normalized to 22 kHz (the upper limit of human ears).
".flac", ".wav", ".w64", ".aif", ".aiff", ".aifc", ".au", ".snd",
".mp3", ".mp2", ".aac", ".m4a", ".m4b", ".mp4", ".ac3", ".eac3",
".ogg", ".oga", ".opus", ".spx", ".mka", ".weba", ".webm",
".wma", ".ape", ".wv", ".tta", ".tak", ".shn", ".mpc",
".caf", ".amr", ".dts", ".voc", ".dsf", ".dff", ".alac"
Similar to the original fakeflac.py, fakeflac-go tends to produce false negatives (i.e. incorrect scores of 100) for some lossy encodes. Specifically, encodes that have sufficiently low magnitude at mid-high frequencies relative to the noise floor, and lack a steep drop-off in magnitude at the cutoff point. This can occur when audio is badly transcoded several times, very poor quality, or naturally very quiet in the upper frequencies, e.g. piano music.
Future versions of fakeflac-go may include improved cutoff detection tests that use e.g. variance to detect a lowpassed noise floor.
Left: Fake flac spectrum that produces a false negative (score 100)
Right: Fake flac spectrum that produces a true positive (score 70)
The default constants included in fakeflac-go are empirical and based on those used in the original fakeflac.py. Tuning of these parameters may improve detection of lossy transcodes. Note that a frequency cutoff is only detected when both the limit and drop tests are satisfied.
Run fakeflac-go -help to see defaults
dx Hz apart to trigger drop testfakeflac-go-generated spectrum plot of "fake" versus real flac
Example spectrograms of "fake" and real flacs, generated using sox
Go
87.5%
Shell
8.7%
Dockerfile
3.8%
A command-line tool to detect "fake" lossless audio files and optionally plot their frequency distribution.
Go
1
39 commits
updated Sep 30, 2026
A command-line tool to detect "fake" lossless audio files and optionally plot their frequency distribution. Analysis of lossy files is also supported.
fakeflac-go estimates the percentage of the audio spectrum effectively remaining after a bad transcode from a lossy source.
Algorithm ported from mevdschee/fakeflac with some adjustments; scores may not match. This algorithm is known to produce false negatives, see Limitations.
go install github.com/drichline/fakeflac-go@v0.1.3
This will compile and install the binary to $GOPATH/bin, where $GOPATH defaults to ~/go on Linux/MacOS and %USERPROFILE%\go on Windows. You may have to add this directory to your system's PATH.
docker run --rm -v ./:/files ghcr.io/drichline/fakeflac-go:v0.1.3 [OPTIONS] [FILES]
For systems using podman:
podman run --rm -v ./:/files ghcr.io/drichline/fakeflac-go:v0.1.3 [OPTIONS] [FILES]
Ensure the command is run from inside the directory containing the audio files, or adjust the volume mount directory.
Note that the container image bundles native ffmpeg, so the -ffmpeg flag is enabled by default.
Untested prebuilt binaries for Linux x86/ARM, MacOS Intel/ARM, and Windows 10+ are provided on the releases page; use at your own risk.
Note: ffmpeg is embedded in fakeflac-go and thus not required to build or run
-ffmpeg uses the system ffmpeg for significantly improved performance, see Usage.$ fakeflac-go fake.flac real.flac
Output:
fake.flac: 73
real.flac: 100
fakeflac-go accepts a space-separated list of filenames, and will ignore unsupported (e.g. text) files. Both lossless (e.g. .flac, .alac, .wav) and lossy (e.g. .mp3) formats are supported. For each file, fakeflac-go will output a score of 0-100 to the terminal, with 100 being a "perfect flac."
The resulting numeric score represents the percentage of "real" frequencies up to 22 kHz present in the input file. Note that scores are only an estimate and may not be accurate for some edge-cases and lossy encoders, see Limitations.
-plot saves the spectrum plot of each file to the current directory, named after the input file with .png appended.
-threads sets the maximum number of active Goroutine workers. Defaults to the number of logical CPU cores present.
-ffmpeg uses the system's ffmpeg instead of embedded ffmpeg, greatly improving performance.
ffmpeg must be available in the system's $PATH-boxcardx, -diff, -dx, and -limit: see Tuning
Usage: fakeflac-go [OPTIONS] [FILES]
Options:
-plot
Enable spectrum plot output
-threads int
Limit number of concurrent processes
-ffmpeg
Use system-installed ffmpeg if available
-boxcardx int
Number of boxcar filter spectrum bins (default 500)
-diff float
Lowpass cutoff magnitude drop test limit (default 1.25)
-dx int
Lowpass cutoff test window size in Hz (default 441)
-limit float
Lowpass cutoff magnitude ratio test limit (default 1.1)
All input files are resampled to a 44.1 kHz 16 bit PCM stream by ffmpeg, so that the frequency range is normalized to 22 kHz (the upper limit of human ears).
".flac", ".wav", ".w64", ".aif", ".aiff", ".aifc", ".au", ".snd",
".mp3", ".mp2", ".aac", ".m4a", ".m4b", ".mp4", ".ac3", ".eac3",
".ogg", ".oga", ".opus", ".spx", ".mka", ".weba", ".webm",
".wma", ".ape", ".wv", ".tta", ".tak", ".shn", ".mpc",
".caf", ".amr", ".dts", ".voc", ".dsf", ".dff", ".alac"
Similar to the original fakeflac.py, fakeflac-go tends to produce false negatives (i.e. incorrect scores of 100) for some lossy encodes. Specifically, encodes that have sufficiently low magnitude at mid-high frequencies relative to the noise floor, and lack a steep drop-off in magnitude at the cutoff point. This can occur when audio is badly transcoded several times, very poor quality, or naturally very quiet in the upper frequencies, e.g. piano music.
Future versions of fakeflac-go may include improved cutoff detection tests that use e.g. variance to detect a lowpassed noise floor.
Left: Fake flac spectrum that produces a false negative (score 100)
Right: Fake flac spectrum that produces a true positive (score 70)
The default constants included in fakeflac-go are empirical and based on those used in the original fakeflac.py. Tuning of these parameters may improve detection of lossy transcodes. Note that a frequency cutoff is only detected when both the limit and drop tests are satisfied.
Run fakeflac-go -help to see defaults
dx Hz apart to trigger drop testfakeflac-go-generated spectrum plot of "fake" versus real flac
Example spectrograms of "fake" and real flacs, generated using sox
Go
87.5%
Shell
8.7%
Dockerfile
3.8%