Added possibility to change bitrate

This commit is contained in:
Jeroen De Meerleer 2019-03-16 15:05:11 +01:00
parent dd38f38e89
commit f4bf02fd11

View File

@ -7,6 +7,7 @@ source="-"
dest="-"
convert=false
verbose=2
bitrate=192
help=false
temp="/tmp/converted"
convertart=false
@ -58,8 +59,8 @@ CheckDeps() {
GetOptions() {
# https://stackoverflow.com/a/29754866
OPTIONS=s:d:t:cav::h
LONGOPTS=source:,dest:,temp:,convert,convert-art,verbose::,help
OPTIONS=s:d:t:cab:v::h
LONGOPTS=source:,dest:,temp:,convert,convert-art,bitrate:,verbose::,help
# -use ! and PIPESTATUS to get exit code with errexit set
# -temporarily store output to be able to check for errors
@ -111,6 +112,10 @@ GetOptions() {
convertart=true
shift
;;
-b|--bitrate)
bitrate="$2"
shift 2
;;
--)
shift
break
@ -149,6 +154,7 @@ Usage() {
echo " -t, --temp <folder> The temporary cache for converted files (default: /tmp/converted)"
echo " -c, --convert Convert files before syncing"
echo " -a, --convert-art Convert album-art before syncing"
echo " -b, --bitrate When converting use this bitrate"
echo " -v, --verbose <0-6> Set log level (default: 2)"
echo " -h, --help Display this help text"
echo ""
@ -243,7 +249,7 @@ ConvertFiles() {
mkdir -p "$temp/${line%/*}";
fi;
if [[ ! -f "$temp/$line" || "${source}/$line" -nt "$temp/$line" ]]; then
lame -b 192 $source/$line $temp/$line 1>/dev/null 2>/dev/null
lame -b ${bitrate} $source/$line $temp/$line 1>/dev/null 2>/dev/null
VerboseOutput 2 "Converted: $line"
if [[ $convertart == true ]]; then
mkdir "$temp/$line-images/"