Skip to content

Instantly share code, notes, and snippets.

@Alexwi1son
Forked from RAM92/convert-flac-to-mp3.sh
Created March 13, 2025 08:09
Show Gist options
  • Save Alexwi1son/3e4fa1a4b718e1a594cb6e6226d5aaaa to your computer and use it in GitHub Desktop.
Save Alexwi1son/3e4fa1a4b718e1a594cb6e6226d5aaaa to your computer and use it in GitHub Desktop.
Script to convert flac files to 320kbps mp3

#! /usr/bin/env nix-shell #! nix-shell -i bash -p ffmpeg_5

trap 'echo "Aborting..."; exit 1' SIGINT

find . -type f -name "*.flac" -print0 | while read -d $'\0' flac_file; do echo "Input file: $flac_file" mp3_file="${flac_file%.flac}.mp3" ffmpeg -nostats -loglevel 0 -nostdin -i "$flac_file" -vn -b:a 320k -acodec libmp3lame "$mp3_file" || { rm "$mp3_file"; exit; }; rm "$flac_file" echo "Converted $mp3_file" done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment