sync/scripts/reencode_m4a.sh

31 lines
789 B
Bash
Raw Normal View History

#!/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
2023-05-27 18:12:05 +02:00
dir="$(pwd)"
dest=${dir%/*}/${dir##*/}_reencode
if [[ !(-d $dest) ]]; then
mkdir $dest
fi
for file in ./*.m4a; do
2023-01-18 22:35:06 +01:00
echo "ffmpeg -i '$file' -c:a $vbr $map -movflags +faststart '$dest/$file'";
ffmpeg -i "$file" -c:a $vbr $map -movflags +faststart "$dest/$file";
done