scripts/audio/mp3car.sh

35 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# mp3car.sh, Copyright © 2014 Matteo Cypriani
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#
# This script uses pacpl (Perl Audio Converter) to convert any audio
# files to low-quality MP3, suitable for listening in a car (default
# parameters are VBR 32-128 kbps, joint stereo).
#
# Dependencies: pacpl, lame
if [ $# -lt 1 ] ; then
printf 'Usage: %s <input> [input [...]]\n' "$0" >&2
exit 1
fi
BASEOUTDIR="$HOME/tmp/mp3car"
LAMEOPTIONS="-v -b 32 -B 128"
for INPUT in "$@" ; do
printf '\n*** CONVERTING "%s" ***\n' "$INPUT"
OUTDIR="$BASEOUTDIR/$(basename "$INPUT")"
printf '\nDestination directory: "%s"\n\n' "$OUTDIR"
mkdir -p "$OUTDIR"
pacpl \
--to mp3 --encoder lame --defopts 0 --eopts "$LAMEOPTIONS" \
--recursive --preserve --outdir "$OUTDIR" \
"$INPUT"
done