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