Skip to content

Instantly share code, notes, and snippets.

@RAM92
Last active March 13, 2025 08:09
Show Gist options
  • Save RAM92/e5c585312e92fb3133d7368399744b4e to your computer and use it in GitHub Desktop.
Save RAM92/e5c585312e92fb3133d7368399744b4e 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