#!/bin/bash
for cmd in ffmpeg parallel; do
if ! command -v $cmd >/dev/null 2>&1; then
echo "Error: $cmd is not installed. Please install $cmd."
exit 1
fi
done
echo "Starting FLAC to ALAC conversion..."
echo "Converting to Apple Lossless format..."
convert_file() {
input="$1"
output="${input%.flac}.m4a"
echo "Converting: $input"
ffmpeg -y -i "$input" -c:a alac -c:v copy -map_metadata 0 "$output" -loglevel warning
}
export -f convert_file
num_cores=14
find . -type f -name "*.flac" -print0 | \
parallel -0 --citation -j$num_cores --bar convert_file
echo "Conversion complete!"