Skip to content

Instantly share code, notes, and snippets.

@natecostello
Last active October 7, 2023 02:26
Show Gist options
  • Save natecostello/7744998350a93f7ef02e87626e0d65b3 to your computer and use it in GitHub Desktop.
Save natecostello/7744998350a93f7ef02e87626e0d65b3 to your computer and use it in GitHub Desktop.
Convert ALAC to AAC

for i in *.m4a; do ffmpeg -i "$i" -c:a aac -b:a 256k "${i%.*}.aac"; done

To determine if alac or acc:

for i in *.m4a; do t=$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$i"); echo $t $i ; done

In a mixed directory, to only convert alac to aac:

for i in *.m4a; do t=$(ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$i"); if [ $t = 'alac' ]; then ffmpeg -i "$i" -c:a aac -b:a 256k "${i%.*}.aac" ; fi; done;

To delete leftover alac:

for i in *.aac; do rm "${i%.*}.m4a"; done

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