Skip to content

Whatsmybitrate analyzes audio files for quality metrics such as bit rate, frequency, and codec type in bulk. It also generates spectrograms for visual representation of the audio spectrum. It supports a variety of audio formats, including MP3, FLAC, WAV, AAC, M4A, and more.

Notifications You must be signed in to change notification settings

oren-cohen/whatsmybitrate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Whats my Bitrate? - Audio Quality Analyzer

Overview

This tool analyzes audio files for quality metrics such as bit rate, frequency, and codec type in bulk. It also generates spectrograms for visual representation of the audio spectrum. It supports a variety of audio formats, including MP3, FLAC, WAV, AAC, M4A, and more.

Features

  • Analyze audio files for detailed quality metrics.
  • Generate spectrograms for audio visualization.
  • Supports multiple file types: mp3, flac, wav, aac, ogg, m4a, aiff.
  • Batch processing of files in a directory.
  • Recursive directory scanning.
  • Multi-threaded processing for faster analysis.
  • Export results in HTML or CSV format.

Requirements

  • Python 3.7 or later
  • FFmpeg (for metadata extraction and file decoding)
  • Required Python libraries (see requirements.txt)

Installation

  1. Clone the repository:

    git clone https://github.com/oren-cohen/whatsmybitrate.git
    cd whatsmybitrate
  2. Install Python dependencies:

    pip install -r requirements.txt
  3. Install FFmpeg:

    • Linux:
      sudo apt update
      sudo apt install ffmpeg
    • MacOS:
      brew install ffmpeg
    • Windows:
      1. Download FFmpeg from ffmpeg.org.
      2. Extract the archive and add the bin folder to your system's PATH.

    To verify FFmpeg installation, run:

    ffmpeg -version

Usage

Basic Command

Analyze all audio files in the current directory and generate a report:

python whatsmybitrate.py -f report.html -l -a  # For HTML report
python whatsmybitrate.py -f report.csv -l -a   # For CSV report

Command-Line Arguments

Argument Description
-f <file> Output report file name (required). Use .html or .csv extension for desired format.
-l Enable logging.
-a Analyze all supported audio types.
-t <type> Analyze a specific file type (e.g., mp3, wav).
-r Scan directories recursively.
-m <threads> Number of threads to use for analysis (default: 1).
-n Disable spectrogram generation (spectrograms are generated by default).
<input> Specify individual files or patterns (e.g., *.mp3, *.wav).

Examples

  1. Analyze all files in a directory recursively:

    python whatsmybitrate.py -f analysis.html -l -a -r /path/to/directory  # HTML report
    python whatsmybitrate.py -f analysis.csv -l -a -r /path/to/directory   # CSV report
  2. Analyze only mp3 files in a directory recursively:

    python whatsmybitrate.py -f mp3_analysis.html -t mp3 -r /path/to/directory  # HTML report
    python whatsmybitrate.py -f mp3_analysis.csv -t mp3 -r /path/to/directory   # CSV report
  3. Analyze specific files:

    python whatsmybitrate.py -f specific_files.html file1.mp3 file2.wav  # HTML report
    python whatsmybitrate.py -f specific_files.csv file1.mp3 file2.wav   # CSV report

Example of re-encoded 128kbps MP3

image

Supported Audio Formats

  • WAV
  • FLAC
  • MP3
  • AAC
  • OGG
  • M4A
  • AIFF

Output

The script can generate reports in two formats:

  • HTML Report (use .html extension): Contains detailed metrics for each file, including:

    • Codec
    • Sample Rate
    • Max Frequency
    • Nyquist Frequency
    • Frequency Ratio
    • Stated Bit Rate
    • Estimated Bitrate
    • Spectrogram image (if generated)
  • CSV Report (use .csv extension): Contains the same metrics in a tabular format suitable for:

    • Importing into spreadsheet software
    • Data analysis and processing
    • Integration with other tools

Note: CSV reports exclude spectrograms as they cannot be represented in CSV format.

Troubleshooting

FFmpeg Not Found

Ensure FFmpeg is installed and added to your system's PATH. Test the installation by running:

ffmpeg -version

Missing Spectrograms

If spectrograms are missing:

  • Ensure matplotlib and librosa are installed:
    pip install matplotlib librosa
  • Check that the audio file is not corrupt or unsupported.

Errors in Logs

If the script encounters errors, enable logging with the -l flag. Review the logs for detailed error messages.

License

This project is not licensed. Do you want you want with it. :)


If you encounter any issues, feel free to open an issue on the GitHub repository.

About

Whatsmybitrate analyzes audio files for quality metrics such as bit rate, frequency, and codec type in bulk. It also generates spectrograms for visual representation of the audio spectrum. It supports a variety of audio formats, including MP3, FLAC, WAV, AAC, M4A, and more.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages