Skip to content

About

A python script to scan a music library and identify FLAC files that were potentially transcoded from lossy formats

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Is This Lossy?

A lightweight python script to scan a music library and identify FLAC files that were potentially transcoded from lossy formats (eg. .mp3 files transcoded to .flac)

These transcoded files do not have any data above a certain frequency range, since the transconding will not create new data, thus they aren't truly lossless files and do not carry any quality improvement, however they do have an increased file size. By identifying these files, one could "downgrade" them back to MP3 or other lossy formats to save on disk space without any quality loss.

Requirements

  • Python 3.x
  • numpy
  • soundfile

Installation

Clone this repository or just download isthislossy.py and requirements.txt.

You can install the required dependencies using your system's package manager or by creating a virtual environment:

python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt

Usage

Run the script from your terminal and point it to the directory containing your flacs:

python isthislossy.py "/home/vrkknn/music"

The script will create a .csv file in the current directory with the results of the scan with the following format:

File Path,Filename,Cutoff Frequency (Hz),Potential Upscale

How it works

The script grabs a 30 second chunk from the middle of each file and runs a fast Fourier transform to analyse the frequency spectrum and calculates where the signal permanently drops 75dB below the loudest peak. If the file has a hard cutoff below 16500Hz, the script will flag it as a potential transcode. This cutoff was chosen because it is a common range in MP3 files (192-320kbps), while usually FLACs and other lossless formats will range from 22000Hz to 44000Hz.

❯ python isthislossy.py "/home/vrkknn/Music/"
Scanning directory: /home/vrkknn/Music/
Results will be saved to: /home/vrkknn/scan_results_2026-04-27_190839.csv

[76/3197] FLAG: 09. The Hardest Button to Button.flac        (Cutoff: 14936 Hz)
[359/3197] FLAG: 01. Dug Your Grave.flac                     (Cutoff: 16479 Hz)
[519/3197] FLAG: 01. Untitled (2025 Remaster).flac           (Cutoff: 15143 Hz)
[520/3197] FLAG: 04. Untitled (FFFFF Version).flac           (Cutoff: 11412 Hz)
[536/3197] Checked: 02. Creep.flac                           (Cutoff: 22050 Hz)

Checking 01. Dug Your Grave.flac using a spectrum analyser:

On False Positives

This script is a great baseline for identifying potentially transcoded files, however false positives should be expected. It will likely flag older recordings due to limitations of equipment of the era, acoustic tracks or tracks with instruments that do not produce higher frequency sounds, lofi songs or songs that make intentional use of low pass filters, among others. On the other hand, some transcodes can have very short peaks going well over the 16500Hz cutoff and the script will not flag the file.

Always use these results as a starting point for proper analysis.

About

A python script to scan a music library and identify FLAC files that were potentially transcoded from lossy formats

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages