Skip to content

Instantly share code, notes, and snippets.

@DevER-M
Created May 31, 2025 14:13
Show Gist options
  • Select an option

  • Save DevER-M/b9ea73926d1aef22ba6a38182fdf5bba to your computer and use it in GitHub Desktop.

Select an option

Save DevER-M/b9ea73926d1aef22ba6a38182fdf5bba to your computer and use it in GitHub Desktop.
flac to aac batch transcoder
#!/bin/bash
set -e
newdir="${PWD##*/}"
mkdir -p "$newdir"
process_file() {
local i="$1"
local out="$newdir/${i%.*}.m4a"
ffmpeg -y -vn -i "$i" -c:a aac_at -q:a 3 -ar 48k "$out" # change your required quality here use fdk_aac or aac if audiotoolbox not supported
if [[ -f cover.jpg ]]; then
convert cover.jpg -resize 500x500 -strip -quality 70 compressed.jpg
AtomicParsley "$out" --artwork compressed.jpg --overWrite >/dev/null
fi
echo "Finished: $i"
}
export -f process_file
export newdir
IFS=$'\n'
find . -maxdepth 1 -name '*.flac' -print0 | parallel -0 -j 4 process_file # change the number threads here
cp cover.jpg "$newdir/cover.jpg"
@DevER-M
Copy link
Author

DevER-M commented May 31, 2025

this needs atomic parsley,ffmpeg and gnu parallel

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