Advanced FLAC authenticity analyzer - Detects MP3-to-FLAC transcodes with high precision
Project description
๐ต FLAC Detective
Advanced FLAC Authenticity Analyzer - v0.6.7
"Every FLAC file tells a story... I find the truth."
FLAC Detective is a professional-grade tool for detecting MP3-to-FLAC transcodes with exceptional precision. Using advanced spectral analysis and multi-rule scoring, it achieves 89.1% authentic detection rate with less than 0.5% false positives.
โจ Features
๐ฏ Advanced 11-Rule Detection System
- Rule 1: MP3 Spectral Signature Detection (CBR patterns) - Enhanced with 20 kHz exception
- Rule 2: Cutoff Frequency Analysis vs Nyquist
- Rule 3: Source vs Container Bitrate Comparison
- Rule 4: Suspicious 24-bit File Detection
- Rule 5: High Variance Protection (VBR)
- Rule 6: High Quality Protection
- Rule 7: Silence & Vinyl Analysis (3 phases)
- Phase 1: Dither detection
- Phase 2: Vinyl surface noise
- Phase 3: Clicks & pops
- Rule 8: Nyquist Exception (95% & 90% thresholds)
- Rule 9: Compression Artifacts Detection
- Test A: Pre-echo (MDCT ghosting)
- Test B: High-frequency aliasing
- Test C: MP3 quantization noise
- Rule 10: Multi-Segment Consistency Analysis
- Rule 11: Cassette Detection (authentic analog source protection)
๐ 4-Level Verdict System
Score โฅ 86 โ FAKE_CERTAIN โ (100% confidence)
Score 61-85 โ SUSPICIOUS โ ๏ธ (High confidence)
Score 31-60 โ WARNING โก (Manual review recommended)
Score โค 30 โ AUTHENTIC โ
(99.5% confidence)
โก Performance Optimizations
- 80% faster than baseline (optimized for large-scale analysis)
- Smart short-circuits for obvious cases
- Parallel execution of expensive rules
- File read caching
- Progressive analysis (2โ5 segments when needed)
๐ฏ Production Metrics
| Metric | Result | Status |
|---|---|---|
| Authentic Rate | 89.1% | โ Excellent |
| Fake Detection | 2.2% | โ Precise |
| False Positives | < 0.5% | โ Minimal |
| Tested Files | 817,631 | โ Large-scale |
| Performance | +80% | โ Optimized |
๐ ๏ธ Installation
From PyPI (Recommended)
pip install flac-detective
From Source
# Clone the repository
git clone https://github.com/GuillainM/FLAC_Detective.git
cd FLAC_Detective
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
# Install development dependencies
pip install -e ".[dev]"
๐ Usage
Command Line
# Analyze current directory
flac-detective .
# Analyze specific directory
flac-detective /path/to/music
# Generate JSON report
flac-detective /path/to/music --format json
# Verbose output
flac-detective /path/to/music --verbose
# Custom output file
flac-detective /path/to/music --output report.txt
Python API
from flac_detective.analysis.new_scoring import new_calculate_score
from pathlib import Path
# Analyze a file
filepath = Path("/path/to/file.flac")
score, verdict, confidence, reasons = new_calculate_score(
cutoff_freq=20500,
metadata={"sample_rate": 44100, "bit_depth": 16, "channels": 2},
duration_check={"duration": 180.5},
filepath=filepath
)
print(f"Verdict: {verdict} (Score: {score}/150)")
print(f"Confidence: {confidence}")
print(f"Reasons: {reasons}")
๐ Documentation
- Changelog - Complete version history
- Technical Documentation - Architecture and algorithms
- Rule Specifications - Detailed rule documentation
- Performance Guide - Optimization strategies
- Project Structure - Directory layout and file descriptions
- Version Management - Release workflow guide
๐๏ธ Architecture
src/flac_detective/
โโโ analysis/
โ โโโ new_scoring/ # Advanced 11-rule scoring system
โ โ โโโ rules/ # Individual rule implementations
โ โ โ โโโ spectral.py # Rules 1, 2, 8 (with 20kHz exception)
โ โ โ โโโ bitrate.py # Rules 3, 4
โ โ โ โโโ silence.py # Rule 7
โ โ โ โโโ artifacts.py # Rule 9
โ โ โ โโโ consistency.py # Rule 10
โ โ โ โโโ cassette.py # Rule 11
โ โ โโโ calculator.py # Orchestration & optimization
โ โ โโโ strategies.py # Strategy pattern implementation
โ โ โโโ models.py # Data models (with energy_ratio)
โ โ โโโ verdict.py # Score interpretation
โ โโโ spectrum.py # Spectral analysis
โ โโโ audio_cache.py # File read optimization
โโโ reporting/ # Report generation
โโโ main.py # CLI entry point
๐งช Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=flac_detective --cov-report=html
# Run specific test
pytest tests/test_new_scoring_rules.py -v
Test Coverage: ~85% overall, 100% for critical rules
๐ How It Works
Detection Process
- Spectral Analysis: Extract frequency spectrum and detect cutoff
- Rule 8 (First): Apply Nyquist protection before other rules
- Fast Rules (R1-R6): Quick checks for obvious cases
- Short-Circuit: Skip expensive rules if verdict is certain
- Expensive Rules (R7, R9): Deep analysis when needed
- Multi-Segment (R10): Validate consistency across file
- Verdict: Interpret final score with confidence level
Protection Hierarchy
LEVEL 1: Absolute Protection
โโ R8 (95-98% Nyquist): -30 to -50 pts
LEVEL 2: Targeted MP3 320k Protection
โโ R1 Exception (90% Nyquist): Skip 320k detection
LEVEL 3: High Quality Protection
โโ R5 (High Variance): -40 pts
โโ R6 (High Quality): -30 pts
โโ R7 (Vinyl/Silence): -50 to -100 pts
LEVEL 4: Dynamic Protection
โโ R10 (Segment Inconsistency): -20 to -30 pts
๐ฏ Use Cases
โ Recommended For
- Collection Cleaning: Remove transcoded files from your library
- Quality Verification: Validate FLAC authenticity before archiving
- Batch Processing: Analyze large music libraries efficiently
- Vinyl Rip Validation: Confirm authentic vinyl sources
โ Not Recommended For
- Lossy Format Analysis: Only works with FLAC files
- Real-time Processing: Designed for batch analysis
- Subjective Quality: Detects transcodes, not audio quality
๐ฎ Roadmap
v0.6 (Planned)
- GUI interface for easier usage
- Configurable sensitivity presets (Strict/Normal/Aggressive)
- Per-rule enable/disable options
- Custom threshold configuration
- HTML reports with spectrograms
- Automatic file organization
Future Considerations
- Support for other lossless formats (ALAC, WAV)
- Machine learning integration
- Cloud-based analysis API
- Music player integration
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Audio analysis community for research on MP3 compression
- Contributors to NumPy, SciPy, and Soundfile libraries
- Beta testers who provided valuable feedback
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
๐ Project Stats
- Version: 0.6.7
- Status: Beta
- Python: 3.8+
- License: MIT
- Detection System: 11 rules with enhanced 20 kHz exception
- Tested: 817,631 files, 89.1% authentic rate
Made with โค๏ธ for audio enthusiasts
FLAC Detective v0.6.7 - Because your music deserves authenticity
Project details
Release history Release notifications | RSS feed
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 flac_detective-0.6.8.tar.gz.
File metadata
- Download URL: flac_detective-0.6.8.tar.gz
- Upload date:
- Size: 124.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1d0642fb952e52f24a187c26b2f694a0c5658265177cec502ea7cd9c4ab72c7
|
|
| MD5 |
3905c2b796b9b26e9b36a13f22c96a95
|
|
| BLAKE2b-256 |
458e9cf8945f3e2f8941de03d495cefb23657795750c2988daec0767aee37661
|
File details
Details for the file flac_detective-0.6.8-py3-none-any.whl.
File metadata
- Download URL: flac_detective-0.6.8-py3-none-any.whl
- Upload date:
- Size: 84.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d110e40e811b8b2f1edef3ace00ce56613eee7afbd6e662ff6460f9eb4430d23
|
|
| MD5 |
412485f84d6ff015b87a0a7d2db13ebb
|
|
| BLAKE2b-256 |
d418860fdb701017f1d9ec10541934fc9a09629b41439a3d19249bf01a531b60
|