Create a gist now

Instantly share code, notes, and snippets.

@zrong /shrink.sh
Last active Mar 6, 2018

What would you like to do?
shrink.sh
#!/bin/bash
##############################
# shrink the mp3 files
# @author rzeng
# @date 2017-02-12
# @update 2018-03-06
# @requirements lame
##############################
if ! [ "$(which lame)" ];then
echo "Install lame first!"
exit 127
fi
input_file=$1
output_dir=$2
if ! [ -f "$input_file" ];then
echo "No input file!"
exit 127
fi
if ! [ -d "$output_dir" ];then
echo "No output dir!"
exit 127
fi
mp3_file=${input_file%.*}.mp3
new_file=$output_dir/$mp3_file
new_dir=$(dirname $new_file)
mkdir -p $new_dir
echo "convert $input_file to $new_file"
lame -m j -V 0 -q 0 -b 45 -B 96 $input_file $new_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment