A clean Python script to recursively convert FLAC files to high-quality MP3 format using ffmpeg.
- Python 3.x
- ffmpeg installed and added to your system's PATH.
- Recursive search for all
.flacfiles in a given directory. - High-quality Variable Bit Rate (VBR) MP3 encoding using
libmp3lame(quality level-q:a 0). - Clean handling of file and folder names containing spaces.
- Robust subprocess call handling.
- Multiple export modes:
- In-place: Saves the
.mp3file next to its corresponding.flacfile. - Save Directory Tree: Re-creates the source directory structure under a target folder.
- Flattened: Exports all converted MP3s directly into a single folder.
- Combined: Allows running both export modes simultaneously, converting once and copying the output file to avoid redundant work.
- In-place: Saves the
- Skip existing files: Optionally skip conversion if the output MP3 file already exists, useful for resuming interrupted batch conversions.
To run the script with default settings (recursively convert FLAC files in-place starting from the current directory):
python flac2mp3.pyYou can optionally specify a target directory to scan and export options:
python flac2mp3.py [search_directory] [options]Converting all flacs from D:\Downloads to D:\mp3s with 4 parallel threads, saving directories tree:
python .\flac2mp3.py D:\Downloads\ --output-directory-save-directories-tree=D:\mp3s\ --parallel-run=4-
--output-directory-save-directories-tree=<path>(or without--prefix:output-directory-save-directories-tree=<path>)Exports MP3 files to
<path>while recreating the subfolder structure. -
--output-directory-without-directories-tree=<path>(or without--prefix:output-directory-without-directories-tree=<path>)Exports all MP3 files directly into
<path>, flattening the subdirectories. -
--parallel-run=<number>(or without--prefix:parallel-run=<number>)Number of concurrent audio conversions (default:
1). -
--skip-output-file-if-existsSkip conversion if the output MP3 file already exists.
Convert all FLAC files under the current directory, saving the MP3s next to the original files:
python flac2mp3.pyConvert FLAC files from C:\Music\FLAC and export them to D:\Music\MP3 preserving the subfolder layout:
python flac2mp3.py C:\Music\FLAC output-directory-save-directories-tree=D:\Music\MP3Convert FLAC files from C:\Music\FLAC and dump all generated MP3s into D:\Music\FlatMP3:
python flac2mp3.py C:\Music\FLAC output-directory-without-directories-tree=D:\Music\FlatMP3Convert FLAC files and save them to both a structured and a flat directory at the same time:
python flac2mp3.py C:\Music\FLAC output-directory-save-directories-tree=D:\Music\MP3 output-directory-without-directories-tree=D:\Music\FlatMP3Convert FLAC files in parallel using 4 concurrent threads:
python flac2mp3.py parallel-run=4Resume an interrupted conversion, skipping files that were already converted:
python flac2mp3.py C:\Music\FLAC --output-directory-save-directories-tree=D:\Music\MP3 --skip-output-file-if-exists