sync/scripts/reencode_m4a.sh

30 lines
758 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# evaluate options through given arguments
map=
vbr=
while [[ $# > 0 ]]; do
case $1 in
-map) map='-map 0:0'; shift;;
-vbr) vbr='libfdk_aac -profile:a aac_he -b:a 64k'; shift;;
* ) break ;; # Anything else stops command line processing.
esac
done
# if no variable bitrate, just copy audio
if [[ -z $vbr ]]; then
map="$map copy"
fi
# ensure existence of destination folder
dest=../reencode
if [[ !(-d $dest) ]]; then
mkdir $dest
fi
for file in ./*.m4a; do
echo "ffmpeg -i '$file' -c:a $vbr $map -movflags +faststart '$dest/$file'";
ffmpeg -i "$file" -c:a $vbr $map -movflags +faststart "$dest/$file";
done